Skip to content

Commit d403b1b

Browse files
committed
Support the new dynamic interval sleep.
While also maintaining backwards compatibility. See resque/resque#1920.
1 parent 5ffae9f commit d403b1b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/resque/pool.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,15 @@ def spawn_worker!(queues)
432432
call_after_prefork!(worker)
433433
reset_sig_handlers!
434434
#self_pipe.each {|io| io.close }
435-
worker.work(ENV['INTERVAL'] || DEFAULT_WORKER_INTERVAL) # interval, will block
435+
# will block until a shutdown signal is received
436+
if worker.method(:work).parameters.size > 2 # Backwards compat
437+
worker.work(ENV["INTERVAL"],
438+
max_interval: ENV['MAX_INTERVAL'],
439+
min_interval: ENV['MIN_INTERVAL'],
440+
backoff_interval: ENV['BACKOFF_INTERVAL'])
441+
else
442+
worker.work(ENV['INTERVAL'] || DEFAULT_WORKER_INTERVAL)
443+
end
436444
end
437445
workers[queues][pid] = worker
438446
call_after_spawn!(worker, pid, workers)

0 commit comments

Comments
 (0)