Class: RabbitWQ::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit_wq/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.banner = "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

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/rabbit_wq/command.rb', line 4

def options
  @options
end

Instance Method Details

#startObject



30
31
32
33
34
35
36
# File 'lib/rabbit_wq/command.rb', line 30

def start
  if options[:interactive]
    start_interactive( options )
  else
    start_daemonized( options )
  end
end

#start_daemonized(options) ⇒ Object



43
44
# File 'lib/rabbit_wq/command.rb', line 43

def start_daemonized( options )
end

#start_interactive(options) ⇒ Object



38
39
40
41
# File 'lib/rabbit_wq/command.rb', line 38

def start_interactive( options )
  server = RabbitWQ::Server.new( options.merge( log: nil ))
  server.start
end