mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Speed up shutdown, only pause 5 seconds if necessary
This commit is contained in:
parent
f214c10af9
commit
25ddfd6174
2 changed files with 12 additions and 5 deletions
|
@ -57,7 +57,7 @@ module Sidekiq
|
|||
sleep
|
||||
rescue Interrupt
|
||||
# TODO Need clean shutdown support from Celluloid
|
||||
logger.info 'Shutting down, pausing 5 seconds to let workers finish...'
|
||||
logger.info 'Shutting down'
|
||||
manager.stop!
|
||||
manager.wait(:shutdown)
|
||||
end
|
||||
|
|
|
@ -35,16 +35,23 @@ module Sidekiq
|
|||
@ready.each(&:terminate)
|
||||
@ready.clear
|
||||
|
||||
after(5) do
|
||||
signal(:shutdown)
|
||||
end
|
||||
|
||||
redis.with_connection do |conn|
|
||||
workers = conn.smembers('workers')
|
||||
workers.each do |name|
|
||||
conn.srem('workers', name) if name =~ /:#{process_id}-/
|
||||
end
|
||||
end
|
||||
|
||||
if @busy.empty?
|
||||
return signal(:shutdown)
|
||||
end
|
||||
|
||||
logger.info("Pausing 5 seconds to allow workers to finish...")
|
||||
after(5) do
|
||||
@busy.each(&:terminate)
|
||||
#@busy.each(&:requeue)
|
||||
signal(:shutdown)
|
||||
end
|
||||
end
|
||||
|
||||
def start
|
||||
|
|
Loading…
Add table
Reference in a new issue