Skip to content
Yousef Ourabi edited this page Oct 21, 2013 · 3 revisions

Daemon-kit has a selection of buitin command line arguments, and allows you to specify your own arguments required by your daemons.

Argument handling

The first argument to any daemon indicates the mode of operation, and can be one of run (default), start or stop.

run & start

The only difference is run won't fork the daemon into the background, and present the output of the loggers to STDOUT.

stop

Stops a running daemon. If the --pidfile argument is provided

Builtin arguments

The following options are handled by daemon-kit:

  • -e, --env environment - The environment of the daemon (defaults to development
  • -l, --log path - Full path to the log file
  • --pid path - Full path to the pid file
  • -v, --version - Prints out the daemon-kit version
  • -h, --help - Prints out the help

Custom arguments

Custom arguments are specified in config/arguments.rb. You have access to two variables when this file is parsed. The first is opts, which is the object yielded from OptionParser.new, the second is @options which is a standard Ruby hash that is later accessible through DaemonKit.arguments.options and can be used in your daemon process.

Here is an example

  opts.on('-f', '--foo FOO', 'Set foo') do |foo|
    @options[:foo] = foo
  end
Clone this wiki locally