Module: LoopHard::SidekiqTrap
- Defined in:
- lib/loop_hard/sidekiq_trap.rb
Overview
If Sidekiq has decided to not process more jobs, then stop looping, to let this job end.
This is a massive hack, and we totally shouldn't be doing this (as per mperham himself!)
https://github.com/mperham/sidekiq/issues/2364
But it's better than an ungraceful shutdown
Also, we can't trap the signals ourselves, since Sidekiq is trapping them, and you can only have one "trap"
Class Method Summary collapse
-
.continue?(options = nil) ⇒ Boolean
Returns false if Sidekiq has decided to stop taking new jobs.
Class Method Details
.continue?(options = nil) ⇒ Boolean
Returns false if Sidekiq has decided to stop taking new jobs. True otherwise.
11 12 13 14 15 16 17 |
# File 'lib/loop_hard/sidekiq_trap.rb', line 11 def continue?( = nil) if defined?(Sidekiq) && Sidekiq.server? && defined?(Sidekiq::Fetcher) && Sidekiq::Fetcher.done? LoopHard.logger.info "Ending loop due to Sidekiq shutting down" return false end return true end |