def initialize(controller)
@controller = controller
@options = {}
@opts = OptionParser.new do |opts|
opts.banner = ''
opts.on('-t', '--ontop', 'Stay on top (does not daemonize)') do |t|
@options[:ontop] = t
end
opts.on('-s', '--shush', 'Silent mode (no output to the terminal)') do |t|
@options[:shush] = t
end
opts.on('-f', '--force', 'Force operation') do |t|
@options[:force] = t
end
opts.on('-n', '--no_wait', 'Do not wait for processes to stop') do |t|
@options[:no_wait] = t
end
opts.on('-w', '--force_kill_waittime SECONDS', Integer, 'Maximum time to wait for processes to stop before force-killing') do |t|
@options[:force_kill_waittime] = t
end
opts.on('--pid_delimiter STRING', 'Text used to separate process number in full process name and pid-file name') do |value|
@options[:pid_delimiter] = value
end
opts.separator ''
opts.separator 'Common options:'
opts.on('-l', '--log_output', 'Enable input/output stream redirection') do |value|
@options[:log_output] = value
end
opts.on('--logfilename FILE', String, 'Custom log file name for exceptions') do |value|
@options[:logfilename] = value
end
opts.on('--output_logfilename FILE', String, 'Custom file name for input/output stream redirection log') do |value|
@options[:output_logfilename] = value
end
opts.on('--log_dir DIR', String, 'Directory for log files') do |value|
@options[:log_dir] = value
end
opts.on('--syslog', 'Enable output redirction into SYSLOG instead of a file') do |value|
@options[:log_output_syslog] = value
end
opts.on_tail('-h', '--help', 'Show this message') do
controller.print_usage
exit
end
opts.on_tail('--version', 'Show version') do
puts "daemons version #{Daemons::VERSION}"
exit
end
end
begin
@usage = @opts.to_s
rescue ::Exception
@usage = " -t, --ontop Stay on top (does not daemonize)\n -f, --force Force operation\n -n, --no_wait Do not wait for processes to stop\n\n Common options:\n -h, --help Show this message\n --version Show version\n"
end
end