Skip to content


Generic linux daemon base class

Originally from

Daemon(pidfile) #

A generic daemon class.

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

If you want to log the output to someplace different that stdout and stderr, also override the echo() and error() methods.

get_pid() #

Get the pid from the pidfile.

is_running() #

Check if a process is running under the specified pid.

remove_pidfile() #

Removes the pidfile.

restart() #

Restart the daemon.

run() #

You should override this method when you subclass Daemon.

It will be called after the process has been daemonized by start() or restart().

set_pid(pid) #

Write the pid to the pidfile.

start() #

Start the daemon.

status() #

Prints the daemon status.

stop(check_running = True) #

Stop the daemon.