Module: ActionSubscriber::Babou
- Defined in:
- lib/action_subscriber/babou.rb
Class Method Summary collapse
- .logger ⇒ Object
- .reload_active_record ⇒ Object
- .shutting_down? ⇒ Boolean
-
.start_subscribers ⇒ Object
Class Methods.
- .stop_server! ⇒ Object
Class Method Details
.logger ⇒ Object
30 31 32 |
# File 'lib/action_subscriber/babou.rb', line 30 def self.logger ::ActionSubscriber::Logging.logger end |
.reload_active_record ⇒ Object
34 35 36 37 38 |
# File 'lib/action_subscriber/babou.rb', line 34 def self.reload_active_record if defined?(::ActiveRecord::Base) && !::ActiveRecord::Base.connected? ::ActiveRecord::Base.establish_connection end end |
.shutting_down? ⇒ Boolean
40 41 42 |
# File 'lib/action_subscriber/babou.rb', line 40 def self.shutting_down? !!@shutting_down end |
.start_subscribers ⇒ Object
Class Methods
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/action_subscriber/babou.rb', line 8 def self.start_subscribers reload_active_record ::ActionSubscriber.setup_default_threadpool! ::ActionSubscriber.setup_subscriptions! ::ActionSubscriber.print_subscriptions ::ActionSubscriber.start_subscribers! logger.info "Action Subscriber connected" ::ActiveSupport::Notifications.instrument("action_subscriber:server_started") while true sleep 1.0 #just hang around waiting for messages break if shutting_down? end logger.info "Stopping subscribers..." ::ActionSubscriber.stop_subscribers! logger.info "Shutting down" ::ActionSubscriber::RabbitConnection.subscriber_disconnect! logger.info "Shutdown complete" ::ActiveSupport::Notifications.instrument("action_subscriber:server_stopped") exit(0) end |
.stop_server! ⇒ Object
44 45 46 |
# File 'lib/action_subscriber/babou.rb', line 44 def self.stop_server! @shutting_down = true end |