daemon package

Submodules

Module contents

* Modified generic daemon class *

Author: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

License: http://creativecommons.org/licenses/by-sa/3.0/

class daemon.Daemon(pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', home_dir='.', umask=18, verbose=1, use_gevent=False, use_eventlet=False, use_cleanup=False)[source]

Bases: object

A generic daemon class.

Usage: subclass the Daemon class and override the run() method.

cleanup()[source]

You should override this method if you need cleanup handlers on shutdown (ie, prior to sigterm handling) and set use_cleanup to True when you subclass Daemon().

daemonize()[source]

Do the UNIX double-fork magic, see Stevens’ “Advanced Programming in the UNIX Environment” for details (ISBN 0201563177).

delpid()[source]

Remove PID file if they are us.

get_pid()[source]

Get process ID.

Return pid:

daemon process ID

Rtype int:

is_running()[source]

Check whether the server is running.

Returns:

True if running, else False

log(*args)[source]
restart()[source]

Restart the daemon

run()[source]

You should override this method when you subclass Daemon. It will be called after the process has been daemonized by start() or restart().

start(*args, **kwargs)[source]

Start the daemon

status()[source]

Get status from the daemon

stop()[source]

Stop the daemon

daemon.timestamp()[source]

Make a UTC timestamp.