Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Created July 14, 2011 15:32
Show Gist options
  • Save amcgregor/1082683 to your computer and use it in GitHub Desktop.
Save amcgregor/1082683 to your computer and use it in GitHub Desktop.
Configuration directives for daemonization.
  • processes (default 1) – number of processes to spawn (0 or None to autodetect cores)
  • respawn (default True) – automatically re-spawn dead slaves in a multi-process environment
  • cwd – change current working directory during daemonization
  • detach (default None; autodetect) – detach from the terminal when daemonizing
  • files
    • preserve (default []) – fileno() descriptors to avoid closing
    • stdin (default os.devnull)
    • stdout (default os.devnull)
    • stderr (default os.devnull)
  • pid
    • name (default None) – filename to store master PID in
    • lock (default ".{0}") – PID lockfile template, e.g. "{0}.lock"
  • security
    • uid – switch user before daemonizing
    • gid – switch group before daemonizing
    • core (default False) – allow the generation of core files
    • chroot – A directory to set the effective root of the subprocesses to.
    • umask (default 0)
  • logging
    • file – log file when using simple configuration
    • level – default logging level for simple configuration
    • configuration – dict-based logging configuration (optional)

Logging Notes

In a multi-process environment (where the master process simply manages the sub-processes), the master process’s logger is configured using the directives above and the child processes log to the master process. This avoids log file contention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment