Sha256: 112c40050273642a1842fde10ab2c5909bf75281a07d39124d1c32d89bb15ae9

Contents?: true

Size: 1.94 KB

Versions: 66

Compression:

Stored size: 1.94 KB

Contents

#!/usr/bin/env ruby

require "action_subscriber/preload"
require "thor"

module ActionSubscriber
  class CLI < ::Thor
    class_option :allow_low_priority_methods, :type => :boolean, :desc => "subscribe to low priority queues in addition to the normal queues", :default => false
    class_option :app, :default => "./config/environment.rb"
    class_option :host
    class_option :hosts
    class_option :password
    class_option :prefetch, :type => :numeric, :desc => "how many messages to hold in the local queue in subscribe mode"
    class_option :pop_interval, :type => :numeric, :desc => "how long to wait between asking for messages (in milliseconds)"
    class_option :port, :type => :numeric
    class_option :threadpool_size, :type => :numeric
    class_option :times_to_pop, :type => :numeric, :desc => "how many messages to get from each queue each time we ask rabbit"
    class_option :username

    desc "start", "Start the action subscriber subscription server"
    long_desc <<-BABOUDESC.strip_heredoc
      Action Subscriber contains a simple subscriber server to manage event subscriptions in a separate process.
    BABOUDESC

    def start
      $0 = "Action Subscriber server #{object_id}"
      ::ActionSubscriber.logger.info "Loading configuration..."

      ::ActionSubscriber::Configuration.configure_from_yaml_and_cli(options)

      ::ActionSubscriber.logger.info "Requiring app..."

      require options[:app]

      ::ActionSubscriber.logger.info "Starting server..."

      # Require action_subscriber if the application did not.
      require "action_subscriber"

      ::ActionSubscriber::Babou.start_subscribers
    end
  end
end

[:INT, :QUIT, :TERM].each do |signal|
  trap(signal) do
    ::ActionSubscriber::Babou.stop_server!
  end
end

trap(:TTIN) {
  ::Thread.new do
    ::ActionSubscriber.print_subscriptions
  end
}

trap(:USR2) {
  ::Thread.new do
    ::ActionSubscriber.print_threadpool_stats
  end.join
}

::ActionSubscriber::CLI.start(ARGV)

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java bin/action_subscriber
action_subscriber-5.3.3 bin/action_subscriber
action_subscriber-5.3.2-java bin/action_subscriber
action_subscriber-5.3.2 bin/action_subscriber
action_subscriber-5.3.1-java bin/action_subscriber
action_subscriber-5.3.1 bin/action_subscriber
action_subscriber-5.3.1.pre-java bin/action_subscriber
action_subscriber-5.3.1.pre bin/action_subscriber
action_subscriber-5.3.0-java bin/action_subscriber
action_subscriber-5.3.0 bin/action_subscriber
action_subscriber-5.2.4-java bin/action_subscriber
action_subscriber-5.2.4 bin/action_subscriber
action_subscriber-5.2.3-java bin/action_subscriber
action_subscriber-5.2.3 bin/action_subscriber
action_subscriber-5.2.2-java bin/action_subscriber
action_subscriber-5.2.2 bin/action_subscriber
action_subscriber-5.2.1-java bin/action_subscriber
action_subscriber-5.2.1 bin/action_subscriber
action_subscriber-5.2.0-java bin/action_subscriber
action_subscriber-5.2.0 bin/action_subscriber