inst-jobs 3.1.12 → 3.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed/worker.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2342458023c7d56e82311cd05089b8a748c266b462289a5ce5ba9c169a89abbe
|
4
|
+
data.tar.gz: b9cf5ced42b4a1d18f3599203c55683218c94d71c9f5671db58c8c49ba502ef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b234730e2acb907a880e564b8e7036ff64e9b3d09c18426779c125e7f7c2dbc83629d1c11157131137b0902a128f1a3cfba968e611a77e82782adabfdca6d96
|
7
|
+
data.tar.gz: d3487c737f65ced442c1219ae929eefd1247bb5753f345d06991634262fa592671ea37c798044b0477f038b2e2958c083bc38b9c5b4d344e9a557ec450cfb400
|
data/lib/delayed/version.rb
CHANGED
data/lib/delayed/worker.rb
CHANGED
@@ -64,6 +64,7 @@ module Delayed
|
|
64
64
|
@max_priority = options[:max_priority]
|
65
65
|
@max_job_count = options[:worker_max_job_count].to_i
|
66
66
|
@max_memory_usage = options[:worker_max_memory_usage].to_i
|
67
|
+
@memory_high_water = options[:worker_memory_high_water]&.to_i || (@max_memory_usage / 2)
|
67
68
|
@work_queue = options.delete(:work_queue) || WorkQueue::InProcess.new
|
68
69
|
@health_check_type = Settings.worker_health_check_type
|
69
70
|
@health_check_config = Settings.worker_health_check_config
|
@@ -99,6 +100,11 @@ module Delayed
|
|
99
100
|
|
100
101
|
def start
|
101
102
|
logger.info "Starting worker"
|
103
|
+
begin
|
104
|
+
Process.setrlimit(:DATA, @max_memory_usage, @max_memory_usage * 2) if @max_memory_usage.positive?
|
105
|
+
rescue Errno::EINVAL
|
106
|
+
# couldn't set an OS-level limit
|
107
|
+
end
|
102
108
|
self.process_name =
|
103
109
|
"start:#{Settings.worker_procname_prefix}#{@queue_name}:#{min_priority || 0}:#{max_priority || "max"}"
|
104
110
|
@self_pipe = IO.pipe
|
@@ -184,10 +190,10 @@ module Delayed
|
|
184
190
|
@exit = true
|
185
191
|
end
|
186
192
|
|
187
|
-
if @
|
193
|
+
if @memory_high_water.positive?
|
188
194
|
memory = sample_memory
|
189
|
-
if memory > @
|
190
|
-
logger.debug "Memory usage of #{memory} exceeds
|
195
|
+
if memory > @memory_high_water
|
196
|
+
logger.debug "Memory usage of #{memory} exceeds high water of #{@memory_high_water}, dying"
|
191
197
|
@exit = true
|
192
198
|
else
|
193
199
|
logger.debug "Memory usage: #{memory}"
|
@@ -233,6 +239,11 @@ module Delayed
|
|
233
239
|
# still reschedule the job though.
|
234
240
|
job.reschedule(e)
|
235
241
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
242
|
+
if e.is_a?(NoMemoryError)
|
243
|
+
GC.start # try and free up some memory before reporting the error
|
244
|
+
logger.debug "Could not allocate memory (max is #{@max_memory_usage}), dying"
|
245
|
+
@exit = true
|
246
|
+
end
|
236
247
|
self.class.lifecycle.run_callbacks(:error, self, job, e) do
|
237
248
|
handle_failed_job(job, e)
|
238
249
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-09-
|
13
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|