Convert the calling process into a daemon. To make the current Python
process into a daemon process, you need two lines of code:
from grizzled.os import daemonize
daemonize.daemonize()
If daemonize() fails for any reason, it throws a DaemonError,
which is a subclass of the standard OSError exception. also logs debug
messages, using the standard Python logging package, to channel
"grizzled.os.daemon".
Adapted from: http://software.clapper.org/daemonize/
See Also:
- Stevens, W. Richard. Unix Network Programming (Addison-Wesley, 1990).
- Parameters:
no_close (bool) - If True, don't close the file descriptors. Useful if the
calling process has already redirected file descriptors to an
output file. Warning: Only set this parameter to True if
you're sure there are no open file descriptors to the calling
terminal. Otherwise, you'll risk having the daemon re-acquire a
control terminal, which can cause it to be killed if someone logs
off that terminal.
pidfile (str) - Path to file to which to write daemon's process ID. The string may
contain a ${pid} token, which is replaced with the process ID
of the daemon. e.g.: /var/run/myserver-${pid}
- Raises:
|