Part of twisted.runner.procmon View Source View In Hierarchy
ProcessMonitor runs processes, monitors their progress, and restarts them 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.
|Instance Variables||threshold||How long a process has to live before the death is considered instant,
in seconds. The default value is 1 second.
|killTime||How long a process being killed has to get its affairs in order before
it gets killed with an unmaskable signal. The default value is 5
|minRestartDelay||The minimum time (in seconds) to wait before attempting to restart a
process. Default 1s.
|maxRestartDelay||The maximum time (in seconds) to wait before attempting to restart a
process. Default 3600s (1h).
|_reactor||A provider of |
|Method||addProcess||Add a new monitored process and start it immediately if the
|Method||removeProcess||Stop the named process and remove it from the list of monitored processes.|
|Method||startService||Start all monitored processes.|
|Method||stopService||Stop all monitored processes and cancel all scheduled process restarts.|
Inherited from Service:
|Method||setName||Set the name of the service.|
|Method||setServiceParent||Set the parent of the service.|
|Method||disownServiceParent||Use this API to remove an
|Method||privilegedStartService||Do preparation work for starting the service.|
Add a new monitored process and start it immediately if the
service is running.
ProcessMonitor.addProcess("name", ['/bin/sh', '-c', shell_script])
|Parameters||name||A name for this process. This value must be unique across all processes
added to this monitor.
|args||The argv sequence for the process to launch.|
|uid||The user ID to use to run the process. If |
|gid||The group ID to use to run the process. If |
|uid|| (type: |
|env||The environment to give to the launched process. See
|Parameters||name||A string that uniquely identifies the process.
True(ie the service is started), the process will be restarted. If the process had been running for more than
ProcessMonitor.thresholdseconds it will be restarted immediately. If the process had been running for less than
ProcessMonitor.thresholdseconds, the restart will be delayed and each time the process dies before the configured threshold, the restart delay will be doubled - up to a maximum delay of maxRestartDelay sec.
|Parameters||name||A string that uniquely identifies the process which exited.
|Parameters||name||The name of the process to be started|
|Parameters||name||The name of the process to be stopped|