Module: ResqueAdmin::Scheduler::SignalHandling
- Included in:
- ResqueAdmin::Scheduler
- Defined in:
- lib/resque/scheduler/signal_handling.rb,
lib/resque/scheduler_admin/signal_handling.rb,
lib/resque_admin/scheduler/signal_handling.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #handle_signals ⇒ Object
-
#register_signal_handlers ⇒ Object
For all signals, set the shutdown flag and wait for current poll/enqueing to finish (should be almost instant).
Instance Attribute Details
#signal_queue ⇒ Object
8 9 10 |
# File 'lib/resque/scheduler/signal_handling.rb', line 8 def signal_queue @signal_queue ||= [] end |
Instance Method Details
#handle_signals ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/resque/scheduler/signal_handling.rb', line 26 def handle_signals loop do sig = signal_queue.shift break unless sig log! "Got #{sig} signal" case sig when 'INT', 'TERM', 'QUIT' then shutdown when 'USR1' then print_schedule when 'USR2' then reload_schedule! end end end |
#register_signal_handlers ⇒ Object
For all signals, set the shutdown flag and wait for current poll/enqueing to finish (should be almost instant). In the case of sleeping, exit immediately.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/resque/scheduler/signal_handling.rb', line 15 def register_signal_handlers (Signal.list.keys & %w(INT TERM USR1 USR2 QUIT)).each do |sig| trap(sig) do signal_queue << sig # break sleep in the primary scheduler thread, alowing # the signal queue to get processed as soon as possible. @th.wakeup if @th && @th.alive? end end end |