Class: Pazuzu::SupervisorRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/pazuzu/supervisor_runner.rb

Overview

Runs the supervisor daemon from the command line.

Instance Method Summary collapse

Constructor Details

#initializeSupervisorRunner

Returns a new instance of SupervisorRunner.



6
7
8
# File 'lib/pazuzu/supervisor_runner.rb', line 6

def initialize
  @run_as_daemon = false
end

Instance Method Details

#run!(arguments = []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pazuzu/supervisor_runner.rb', line 10

def run!(arguments = [])
  OptionParser.new do |opts|
    opts.banner = "Usage: #{prog_name} [OPTIONS]"
    opts.separator ""
    opts.on("-d", "--daemon", 'Run as daemon') do
      @run_as_daemon = true
    end
    opts.on("-p PATH", "--pid", "Store pid in PATH (defaults to #{DEFAULT_PID_PATH})") do |value|
      @pid_path = File.expand_path(value)
    end
    opts.on("-c FILE", "--config FILE", "Read configuration from FILE (defaults to #{DEFAULT_CONFIG_PATH})") do |value|
      @config_path = File.expand_path(value)
    end
    opts.on("-h", "--help", "Show this help.") do
      puts opts
      exit
    end
    opts.parse!(arguments)
  end

  if @run_as_daemon
    daemonize!
  else
    execute!
  end
rescue => e
  abort "#{prog_name}: #{e.message}"
end