Sha256: e98f6289e685c4880ae11985de82e3268c261fc26612a7510072d6f1cb932e50
Contents?: true
Size: 1.29 KB
Versions: 12
Compression:
Stored size: 1.29 KB
Contents
require "active_support/notifications" module ActionSubscriber module Babou ## # Class Methods # 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 def self.logger ::ActionSubscriber::Logging.logger end def self.reload_active_record if defined?(::ActiveRecord::Base) && !::ActiveRecord::Base.connected? ::ActiveRecord::Base.establish_connection end end def self.shutting_down? !!@shutting_down end def self.stop_server! @shutting_down = true end end end
Version data entries
12 entries across 12 versions & 1 rubygems