Skip to content

Commit 400c6ec

Browse files
wuputahhone
authored andcommitted
move term timeout to a setting
1 parent 564a8b2 commit 400c6ec

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/resque/tasks.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
worker = Resque::Worker.new(*queues)
1515
worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
1616
worker.very_verbose = ENV['VVERBOSE']
17+
worker.term_timeout = ENV['RESQUE_TERM_TIMEOUT'] || 4.0
1718
rescue Resque::NoQueueError
1819
abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
1920
end

lib/resque/worker.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Worker
2020
# Automatically set if a fork(2) fails.
2121
attr_accessor :cant_fork
2222

23+
attr_accessor :term_timeout
24+
2325
attr_writer :to_s
2426

2527
# Returns an array of all worker objects.
@@ -307,7 +309,7 @@ def kill_child
307309
unless Process.waitpid(@child, Process::WNOHANG)
308310
log! "Sending TERM signal to child #{@child}"
309311
Process.kill("TERM", @child)
310-
50.times do |i|
312+
(term_timeout.to_f * 10).round.times do |i|
311313
sleep(0.1)
312314
return if Process.waitpid(@child, Process::WNOHANG)
313315
end

0 commit comments

Comments
 (0)