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:
parent
2fc1d81cc9
commit
57d11664b1
2 changed files with 6 additions and 4 deletions
|
@ -90,7 +90,7 @@ module Sidekiq
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
logger.info 'Shutting down'
|
logger.info 'Shutting down'
|
||||||
launcher.stop
|
launcher.stop
|
||||||
fire_event(:shutdown)
|
fire_event(:shutdown, true)
|
||||||
# Explicitly exit so busy Processor threads can't block
|
# Explicitly exit so busy Processor threads can't block
|
||||||
# process shutdown.
|
# process shutdown.
|
||||||
exit(0)
|
exit(0)
|
||||||
|
@ -125,7 +125,7 @@ module Sidekiq
|
||||||
when 'USR1'
|
when 'USR1'
|
||||||
Sidekiq.logger.info "Received USR1, no longer accepting new work"
|
Sidekiq.logger.info "Received USR1, no longer accepting new work"
|
||||||
launcher.manager.async.stop
|
launcher.manager.async.stop
|
||||||
fire_event(:quiet)
|
fire_event(:quiet, true)
|
||||||
when 'USR2'
|
when 'USR2'
|
||||||
if Sidekiq.options[:logfile]
|
if Sidekiq.options[:logfile]
|
||||||
Sidekiq.logger.info "Received USR2, reopening log file"
|
Sidekiq.logger.info "Received USR2, reopening log file"
|
||||||
|
|
|
@ -39,8 +39,10 @@ module Sidekiq
|
||||||
@@identity ||= "#{hostname}:#{$$}:#{process_nonce}"
|
@@identity ||= "#{hostname}:#{$$}:#{process_nonce}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fire_event(event)
|
def fire_event(event, reverse=false)
|
||||||
Sidekiq.options[:lifecycle_events][event].each do |block|
|
arr = Sidekiq.options[:lifecycle_events][event]
|
||||||
|
arr.reverse! if reverse
|
||||||
|
arr.each do |block|
|
||||||
begin
|
begin
|
||||||
block.call
|
block.call
|
||||||
rescue => ex
|
rescue => ex
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue