class Chore::CLI
Class that handles the command line interactions in Chore
. It primarily is responsible for invoking the Chore
process with the provided configuration to begin processing jobs.
Attributes
options[R]
registered_opts[R]
Public Class Methods
new()
click to toggle source
# File lib/chore/cli.rb, line 21 def initialize @options = {} @registered_opts = {} @stopping = false end
register_option(key,*args,&blk)
click to toggle source
register_option
is a method for plugins or other components to register command-line config options.
-
key
is the name for this option that can be referenced from Chore.config.key
-
*args
is anOptionParser
style list of options. -
&blk
is an option block, passed toOptionParser
Examples¶ ↑
Chore::CLI.register_option 'sample', '-s', '--sample-key SOME_VAL', 'A description of this value' Chore::CLI.register_option 'something', '-g', '--something-complex VALUE', 'A description' do |arg| # make sure your key here matches the key you register options[:something] arg.split(',') end
# File lib/chore/cli.rb, line 40 def self.register_option(key,*args,&blk) instance.register_option(key,*args,&blk) end
Public Instance Methods
run!(args=ARGV)
click to toggle source
Start up the consuming side of the application. This calls Chore::Manager#start
.
# File lib/chore/cli.rb, line 50 def run!(args=ARGV) parse(args) @manager = Chore::Manager.new @manager.start end
shutdown()
click to toggle source
Begins the Chore
shutdown process. This will call Chore::Manager#shutdown if it is not already in the process of stopping Exits with code 0
# File lib/chore/cli.rb, line 58 def shutdown unless @stopping @stopping = true @manager.shutdown! if @manager exit(0) end end
Private Instance Methods
validate_strategy!()
click to toggle source
# File lib/chore/cli.rb, line 272 def validate_strategy! consumer_strategy = Chore.config.consumer_strategy.to_s worker_strategy = Chore.config.worker_strategy.to_s throttled_consumer = 'Chore::Strategy::ThrottledConsumerStrategy' preforked_worker = 'Chore::Strategy::PreForkedWorkerStrategy' if consumer_strategy == throttled_consumer || worker_strategy == preforked_worker unless consumer_strategy == throttled_consumer && worker_strategy == preforked_worker puts "==================================================================" puts " PreForkedWorkerStrategy may only be paired with " puts " ThrottledConsumerStrategy or vice versa " puts " Please check your configurations " puts "==================================================================" exit(1) end end end