mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Manager now fires stop-related events
Gives more fine-grained control as to when the actual event fires. We also give a small bit of time for the event processors to take effect for those handlers with asynchronous side effects (like shutting down other threads and subsystems).
This commit is contained in:
parent
6698bdc02e
commit
8ffdb36351
2 changed files with 7 additions and 2 deletions
|
@ -97,7 +97,6 @@ module Sidekiq
|
|||
rescue Interrupt
|
||||
logger.info 'Shutting down'
|
||||
launcher.stop
|
||||
fire_event(:shutdown, true)
|
||||
# Explicitly exit so busy Processor threads can't block
|
||||
# process shutdown.
|
||||
exit(0)
|
||||
|
@ -134,7 +133,6 @@ module Sidekiq
|
|||
when 'USR1'
|
||||
Sidekiq.logger.info "Received USR1, no longer accepting new work"
|
||||
launcher.quiet
|
||||
fire_event(:quiet, true)
|
||||
when 'USR2'
|
||||
if Sidekiq.options[:logfile]
|
||||
Sidekiq.logger.info "Received USR2, reopening log file"
|
||||
|
|
|
@ -52,10 +52,17 @@ module Sidekiq
|
|||
|
||||
logger.info { "Terminating quiet workers" }
|
||||
@workers.each { |x| x.terminate }
|
||||
fire_event(:quiet, true)
|
||||
end
|
||||
|
||||
def stop(deadline)
|
||||
quiet
|
||||
fire_event(:shutdown, true)
|
||||
|
||||
# some of the shutdown events can be async,
|
||||
# we don't have any way to know when they're done but
|
||||
# give them a little time to take effect
|
||||
sleep 0.5
|
||||
return if @workers.empty?
|
||||
|
||||
logger.info { "Pausing to allow workers to finish..." }
|
||||
|
|
Loading…
Reference in a new issue