DaemonRunnerWrapper¶
Module for creating generic, callback based wrappers.
It is little bit easier (at least for me) to use than the original daemon module.
-
class
edeposit.amqp.daemonwrapper.
DaemonRunnerWrapper
(pid_filename)[source]¶ Bases:
object
Generic daemon class, which allows you to daemonize your script and react to events in simple callbacks.
Parameters: pid_filename (str) – name of daemon’s PID file, which is stored in /tmp
. Class automatically adds.pid
suffix.-
body
()[source]¶ Here should be your code loop.
Note
Loop is automatically break-ed when daemon receives one of the unix signals. After that,
onExit()
is called.
-
isRunning
()[source]¶ Check PID and return true, if it looks like there is already a running instance of daemon.
PID timeout can be set thru
pidfile_timeout
property.
-
onExit
()[source]¶ Called when the daemon received ?SIGTERM? and is shutting down.
Warning
You should probably put something here, by default is there only shutdown message “DaemonRunnerWrapper is shutting down.”
-
onIsRunning
()[source]¶ Oposite of
onStopFail()
- this callback is called if there is already a running instance of daemon.
-
onStopFail
()[source]¶ Called when it is not possible to stop the daemon.
This kind of event typically occurs if there is no running instance of daemon and script is called with
stop
parameter.
-