1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Execute event handlers in reverse for shutdown, fixes #2374

This commit is contained in:
Mike Perham 2015-06-02 20:33:01 -07:00
parent 2fc1d81cc9
commit 57d11664b1
2 changed files with 6 additions and 4 deletions

View file

@ -90,7 +90,7 @@ module Sidekiq
rescue Interrupt
logger.info 'Shutting down'
launcher.stop
fire_event(:shutdown)
fire_event(:shutdown, true)
# Explicitly exit so busy Processor threads can't block
# process shutdown.
exit(0)
@ -125,7 +125,7 @@ module Sidekiq
when 'USR1'
Sidekiq.logger.info "Received USR1, no longer accepting new work"
launcher.manager.async.stop
fire_event(:quiet)
fire_event(:quiet, true)
when 'USR2'
if Sidekiq.options[:logfile]
Sidekiq.logger.info "Received USR2, reopening log file"

View file

@ -39,8 +39,10 @@ module Sidekiq
@@identity ||= "#{hostname}:#{$$}:#{process_nonce}"
end
def fire_event(event)
Sidekiq.options[:lifecycle_events][event].each do |block|
def fire_event(event, reverse=false)
arr = Sidekiq.options[:lifecycle_events][event]
arr.reverse! if reverse
arr.each do |block|
begin
block.call
rescue => ex