5 $
:.unshift File
.join(File
.dirname(__FILE__
), *%w
[.. lib
])
12 options
= {:daemonize => true, :port => 17165, :syslog => true}
14 opts
= OptionParser
.new
do |opts
|
18 god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D]
21 god <command> <argument> [-p <port>]
22 god <command> [-p <port>]
24 god -V (must be run as root to be accurate on Linux)
27 start <task or group name> start task or group
28 restart <task or group name> restart task or group
29 stop <task or group name> stop task or group
30 monitor <task or group name> monitor task or group
31 unmonitor <task or group name> unmonitor task or group
32 remove <task or group name> remove task or group from god
33 load <file> load a config into a running god
34 log <task name> show realtime log for given task
35 status show status of each task
37 terminate stop god and all tasks
38 check run self diagnostic
43 opts
.on("-cCONFIG", "--config-file CONFIG", "Configuration file") do |x
|
47 opts
.on("-pPORT", "--port PORT", "Communications port (default 17165)") do |x
|
51 opts
.on("-b", "--auto-bind", "Auto-bind to an unused port number") do
55 opts
.on("-PFILE", "--pid FILE", "Where to write the PID file") do |x
|
59 opts
.on("-lFILE", "--log FILE", "Where to write the log file") do |x
|
63 opts
.on("-D", "--no-daemonize", "Don't daemonize") do
64 options
[:daemonize] = false
67 opts
.on("-v", "--version", "Print the version number and exit") do
68 options
[:version] = true
71 opts
.on("-V", "Print extended version and build information") do
75 opts
.on("--log-level LEVEL", "Log level [debug|info|warn|error|fatal]") do |x
|
76 options
[:log_level] = x
.to_sym
79 opts
.on("--no-syslog", "Disable output to syslog") do
80 options
[:syslog] = false
87 if options
[:log_level] && ![:debug, :info, :warn, :error, :fatal].include?(options
[:log_level])
88 abort("Invalid log level '#{options[:log_level]}'")
92 if !options
[:config] && options
[:version]
94 God
::CLI::Version.version
95 elsif !options
[:config] && options
[:info]
97 God
::CLI::Version.version_extended
98 elsif !options
[:config] && command
= ARGV[0]
100 God
::CLI::Command.new(command
, options
, ARGV)
102 require 'god/cli/run'
103 God
::CLI::Run.new(options
)
105 rescue Exception
=> e
106 if e
.instance_of
?(SystemExit
)
109 puts
'Uncaught exception'
111 puts e
.backtrace
.join("\n")