Module: GoogleSubscriber::LifeCycle
- Included in:
- GoogleSubscriber
- Defined in:
- lib/google_subscriber/life_cycle.rb
Instance Method Summary collapse
Instance Method Details
#boot ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/google_subscriber/life_cycle.rb', line 3 def boot GoogleSubscriber.logger.info('booting subscribers') load_subscribers active_subscribers = start_subscribers GracefulShutdown.handle_signals do begin sleep rescue Shutdown => e GoogleSubscriber.shutdown(active_subscribers) e.continue end end end |
#shutdown(active_subscribers) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/google_subscriber/life_cycle.rb', line 18 def shutdown(active_subscribers) GoogleSubscriber.logger.info('shutting down subscribers') return if active_subscribers.nil? active_subscribers.each do |sub| begin sub.stop.wait! rescue => e # swallow error so the remaining active_subscribers can be shut down GoogleSubscriber.logger.error("Error shutting down #{sub}: #{e.message}") end GoogleSubscriber.logger.info('stopped subscriber(s)!') end end |