Module twisted.runner.procmon
ProcessMonitor: run processes, monitor progress, and restart when they
die.
The ProcessMonitor will not attempt to restart a process that appears
to die instantly -- with each "instant" death (less than 1
second, by default), it will delay approximately twice as long before
restarting it. A successful run will reset the counter.
The primary interface is "addProcess" and
"removeProcess". When the service is active (that is, when the
application it is attached to is running), adding a process automatically
starts it.
Each process has a name (a string). This string must uniquely identify
the process. In particular, attempting to add two processes with the same
name will result in a key error.
The arguments to addProcess are:
-
name -- a string, uniquely specifying the process
-
args -- a list of arguments. the first will be used to determine
the executable
-
optionally, the uid and gid this process should be run as (by
default, it does not change uid/gid before running processes).
Note that args are passed to the system call, not to the shell. If
running the shell is desired, the common idiom is to use
.addProcess("name", ['/bin/sh', '-c', shell_script])
removeProcess takes just the name argument. If the process is started,
it kills it, and will never restart it.
The "restartAll" method restarts all processes. This is
useful for 3rd parties management services to allow a user to restart
servers because of an outside circumstances change -- for example, a new
version of a library which is installed.
The following attributes on the monitor can be set to configure
behaviour
-
threshold -- how long a process has to live before the death is
considered instant (default 1, measured in seconds)
-
killTime -- how long a process being killed has to get its affairs
in order before it gets killed with an unmaskable signal (default 5,
measured in seconds)
-
consistencyDelay -- time between consistency checks (default 60,
measured in seconds)
transport
-
- Type:
-
DummyTransport
- Value:
<twisted.runner.procmon.DummyTransport instance at 0x8cb7194>
|
|