Sha256: b78845762e0ec74c80ceaad7eb81856338dccb6af9ba2286c1e11a10440288a2

Contents?: true

Size: 1.08 KB

Versions: 42

Compression:

Stored size: 1.08 KB

Contents

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"

      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"
      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

42 entries across 42 versions & 1 rubygems

Version Path
action_subscriber-5.2.3-java lib/action_subscriber/babou.rb
action_subscriber-5.2.3 lib/action_subscriber/babou.rb
action_subscriber-5.2.2-java lib/action_subscriber/babou.rb
action_subscriber-5.2.2 lib/action_subscriber/babou.rb
action_subscriber-5.2.1-java lib/action_subscriber/babou.rb
action_subscriber-5.2.1 lib/action_subscriber/babou.rb
action_subscriber-5.2.0-java lib/action_subscriber/babou.rb
action_subscriber-5.2.0 lib/action_subscriber/babou.rb
action_subscriber-5.1.5-java lib/action_subscriber/babou.rb
action_subscriber-5.1.5 lib/action_subscriber/babou.rb
action_subscriber-5.1.4-java lib/action_subscriber/babou.rb
action_subscriber-5.1.4 lib/action_subscriber/babou.rb
action_subscriber-5.1.4.pre0 lib/action_subscriber/babou.rb
action_subscriber-5.1.4.pre0-java lib/action_subscriber/babou.rb
action_subscriber-5.1.3 lib/action_subscriber/babou.rb
action_subscriber-5.1.3-java lib/action_subscriber/babou.rb
action_subscriber-5.1.3.pre2 lib/action_subscriber/babou.rb
action_subscriber-5.1.3.pre2-java lib/action_subscriber/babou.rb
action_subscriber-5.1.3.pre1 lib/action_subscriber/babou.rb
action_subscriber-5.1.3.pre1-java lib/action_subscriber/babou.rb