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.
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.
KeyError
.
Instance Variables | threshold | How long a process has to live before the death is considered instant,
in seconds. The default value is 1 second.
(type: float
) |
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
seconds.
(type: float
) | |
consistencyDelay | The time between consistency checks. The default value is 60
seconds.
(type: float
) |
Method | __init__ | Undocumented |
Method | __getstate__ | Undocumented |
Method | addProcess | Add a new process to launch, monitor, and restart when necessary. |
Method | removeProcess | If the process is started, kill it. It will never get restarted. |
Method | startService | Start the service. |
Method | stopService | Stop the service. |
Method | connectionLost | Undocumented |
Method | startProcess | Undocumented |
Method | stopProcess | Undocumented |
Method | restartAll | Restart all processes. This is useful for third party management |
Method | __repr__ | Undocumented |
Method | _checkConsistency | Undocumented |
Method | _forceStopProcess | Undocumented |
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 IService
from an IServiceCollection .
|
Method | privilegedStartService | Do preparation work for starting the service. |
Add a new process to launch, monitor, and restart when necessary.
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
for removing processes from the monitor.
Parameters | name | A label for this process. This value must be unique across all
processes added to this monitor.
(type: str
) |
args | The argv sequence for the process to launch. | |
uid | The user ID to use to run the process. If None , the
current UID is used.
(type: int
) | |
gid | The group ID to use to run the process. If None , the
current GID is used.
| |
uid | (type: int
) | |
env | The environment to give to the launched process. See
IReactorProcess.spawnProcess 's env parameter.
(type: dict
) |
If the process is started, kill it. It will never get restarted.
SeeaddProcess
for adding processes to the monitor.
Parameters | name | The string that uniquely identifies the process.
(type: str
) |
Returns | a Deferred which is triggered when the service has finished
shutting down. If shutting down is immediate, a value can be returned
(usually, None ).
(type: Deferred
) |