t.r.p.ProcessMonitor(service.Service) : class documentation

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.

Each process has a name. This name string must uniquely identify the process. In particular, attempting to add two processes with the same name will result in a KeyError.
Instance VariablesthresholdHow long a process has to live before the death is considered instant, in seconds. The default value is 1 second. (type: float )
killTimeHow 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 )
consistencyDelayThe 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 No summary
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.
def __init__(self): (source)
Undocumented
def __getstate__(self): (source)
Undocumented
def _checkConsistency(self): (source)
Undocumented
def addProcess(self, name, args, uid=None, gid=None, env={}): (source)

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])

See removeProcess for removing processes from the monitor.
ParametersnameA label for this process. This value must be unique across all processes added to this monitor. (type: str )
argsThe argv sequence for the process to launch.
uidThe user ID to use to run the process. If None, the current UID is used. (type: int )
gidThe group ID to use to run the process. If None, the current GID is used.
uid (type: int )
envThe environment to give to the launched process. See IReactorProcess.spawnProcess's env parameter. (type: dict )
def removeProcess(self, name): (source)

If the process is started, kill it. It will never get restarted.

See addProcess for adding processes to the monitor.
ParametersnameThe string that uniquely identifies the process. (type: str )
def startService(self): (source)
Start the service.
def stopService(self): (source)
Stop the service.
Returnsa 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 )
def connectionLost(self, name): (source)
Undocumented
def startProcess(self, name): (source)
Undocumented
def _forceStopProcess(self, proc): (source)
Undocumented
def stopProcess(self, name): (source)
Undocumented
def restartAll(self): (source)
Restart all processes. This is useful for third party management services to allow a user to restart servers because of an outside change in circumstances -- for example, a new version of a library is installed.
def __repr__(self): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:12:41.