Configuring your daemon

daemon-kit provides a multitude of ways to configure your daemon, this document will outline the different options available to you.

Configuration files and DaemonKit::Config

DaemonKit::Config gives you easy access to any YAML configuration files you have in your config directory.

You can access the configuration files like this:

  config = DaemonKit::Config.load('sample')

The above snippet relies on the presence of a config/sample.yml file.

DaemonKit::Config is environment aware, so configuration files are parsed for a top-level key that is the same as the value of DAEMON_ENV, and if present is loaded into the object as the configuration data. If the key is not present, the whole YAML document is exposed as configuration data.

Command line arguments

The most flexible way to configure your daemon is through command line arguments, or switches.

DaemonKit includes a couple of its own arguments that can be used:

  -e ENV (or --env ENV) to set the daemon environment
  --pid /path/to/pidfile to set the path to a pidfile
  -l path (or --log path) to set the path for the log file
  -v shows the DaemonKit version
  -h shows a useful help message

Custom arguments

It is possible for you to specify your own arguments as well, by updating the config/arguments.rb file. This file is eval’d inside DaemonKit::Arguments and gives you access to the following two variables:

Your custom arguments can be accessed like this:

  DaemonKit.arguments.options

Advanced Configuration

All the writable attributes of the default DaemonKit::Configuration instance call also be modified from the command line using the special —config arguments:

  --config force_kill_wait=30

This happens after config/environment.rb is processed, so all command line arguments will overwrite those values.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.