Class: RabbitWQ::Command
- Inherits:
-
Object
- Object
- RabbitWQ::Command
- Defined in:
- lib/rabbit_wq/command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ Command
constructor
A new instance of Command.
- #start ⇒ Object
- #start_daemonized(options) ⇒ Object
- #start_interactive(options) ⇒ Object
Constructor Details
#initialize(args) ⇒ Command
Returns a new instance of Command.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rabbit_wq/command.rb', line 6 def initialize( args ) @options = { :quiet => true, :pid_dir => "#{Rails.root}/tmp/pids" } opts = OptionParser.new do |opts| opts. = "Usage: #{File.basename($0)} [options] start|stop|restart" opts.on('-h', '--help', 'Show this message') do puts opts exit 1 end opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir| @options[:pid_dir] = dir end opts.on('-i', '--interactive', 'Start the process in interactive mode.') do |n| @options[:interactive] = true end end @args = opts.parse!( args ) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/rabbit_wq/command.rb', line 4 def @options end |
Instance Method Details
#start ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rabbit_wq/command.rb', line 30 def start if [:interactive] start_interactive( ) else start_daemonized( ) end end |
#start_daemonized(options) ⇒ Object
43 44 |
# File 'lib/rabbit_wq/command.rb', line 43 def start_daemonized( ) end |