2.2. Process Control

2.2.1. supervisor.getProcessInfo()

supervisor.getProcessInfo(namespec)

Table 2.19. supervisor.getProcessInfo() Parameters

Type Name Description
string namespec Name of the group and process

Table 2.20. supervisor.getProcessInfo() Return Value

Type Description
struct
{'name':           'process name',
 'group':          'group name',
 'start':          1200361776,
 'stop':           0,
 'now':            1200361812,
 'state':          1,
 'statename':      'RUNNING',
 'spawnerr':       '',
 'exitstatus':     0,
 'stdout_logfile': '/path/to/stdout-log',
 'stderr_logfile': '/path/to/stderr-log',
 'pid':            1}

string name - name of the process

string group - name of the process' group

int start - UNIX timestamp of when the process was started

int stop - UNIX timestamp of when the process ended, or 0 if the process is still running.

int now - UNIX timestamp of the current time, which can be used to calculate process up-time.

int state - State code, see table below.

string statename - String description of state, see table below.

string stdout_logfile - absolute path and filename to the STDOUT logfile

string stderr_logfile - absolute path and filename to the STDOUT logfile

string spawnerr - Description of error that occurred during spawn, or empty string if none.

int exitstatus - Exit status (errorlevel) of process, or 0 if the process is still running.

int pid - UNIX process ID (PID) of the process, or 0 if the process is not running.

Returns information about a process. Supervisor maintains a table of processes under its control and can return information about them to the client at any time.

2.2.2. supervisor.getAllProcessInfo()

supervisor.getAllProcessInfo()

Table 2.21. supervisor.getAllProcessInfo() Parameters

Type Name Description

Table 2.22. supervisor.getAllProcessInfo() Return Value

Type Description
array Array of structs, same as returned by supervisor.getProcessInfo().

supervisor.getAllProcessInfo() returns an array containing n number of elements, where n is the number of processes in Supervisor’s process table.

Each element contains a struct, and this struct contains the exact same elements as the struct returned by supervisor.getProcess(). If the process table is empty, an empty array is returned.

2.2.3. supervisor.startProcess()

supervisor.startProcess(namespec, wait=True)

Table 2.23. supervisor.startProcess() Parameters

Type Name Description
string namespec Name of the group and process
boolean wait Wait for start to complete before returning?

Table 2.24. supervisor.startProcess() Return Value

Type Description
boolean Always TRUE

The supervisor.startProcess() method will start a process. If name of the group and process (namespec argument) is not recognized, the fault BAD_NAME will be raised.

If wait=False, the method will return immediately without waiting for Supervisor to start the process.

If wait=True, Supervisor will attempt to start the process and then will hold the HTTP request until the process has reached startsecs.

If the process starts successfully, the boolean TRUE is returned. Otherwise, the fault ABNORMAL_TERMINATION is raised.

2.2.4. supervisor.stopProcessGroup()

supervisor.stopProcessGroup(name)

Table 2.25. supervisor.stopProcessGroup() Parameters

Type Name Description
string name Group name to stop

Table 2.26. supervisor.stopProcessGroup() Return Value

Type Description
boolean Always TRUE

This method will unceremoniously kill all processes within a process group. In normal operations, processes will always terminate on their own. This method will only be used to terminate runaway processes or otherwise kill a process prematurely.

If name of the group (name argument) is not recognized, the fault BAD_NAME will be raised.

If any process cannot be stopped then the fault FAILED will be raised. This is abnormal and results in Supervisor being in a potentially unstable condition.

This method is asynchronous. It will return before the processes have been killed. Once each process has been killed, they will be removed from Supervisor’s process table.

2.2.5. supervisor.stopProcess()

supervisor.stopProcess(namespec)

Table 2.27. supervisor.stopProcess() Parameters

Type Name Description
string namespec Name of the group and process
string namespec Name of the process

Table 2.28. supervisor.stopProcess() Return Value

Type Description
boolean Always TRUE

This method will unceremoniously kill a single process. In normal operations, processes will always terminate on their own. This method will only be used to terminate runaway processes or otherwise kill a process prematurely.

If namespec is not recognized, the fault BAD_NAME will be raised.

If any process cannot be stopped then the fault FAILED will be raised. This is abnormal and results in Supervisor being in a potentially unstable condition.

If the wait argument is True, Supervisor will hold the client’s HTTP request until the process has actually been killed. Once a process has been killed, it will be removed from Supervisor’s process table.

2.2.6. supervisor.stopAllProcesses()

supervisor.stopAllProcesses()

Table 2.29. supervisor.stopAllProcesses() Parameters

Type Name Description

Table 2.30. supervisor.stopAllProcesses() Return Value

Type Description
boolean Always TRUE

This method will unceremoniously kill all processes that are running. It is the equivalent of calling supervisor.stopProcess() on every running process.

If any process cannot be stopped then the fault FAILED will be raised. This is abnormal and results in Supervisor being in a potentially unstable condition.

This method is asynchronous. It will return before the processes have been killed. Once each process has been killed, they will be removed from Supervisor’s process table.

2.2.7. supervisor.sendProcessStdin()

supervisor.sendProcessStdin(namespec, chars)

Table 2.31. supervisor.sendProcessStdin() Parameters

Type Name Description
string namespec Name of the group and process
string chars Character data to push into the process’ STDIN file descriptor

Table 2.32. supervisor.sendProcessStdin() Return Value

Type Description
boolean Always TRUE

The supervisor.sendProcessStdin() method passes a string of characters (parameter chars) into a process' STDIN file descriptor. Supervisor does not terminate the string in any way; it passes the string exactly as it is given in the chars parameter. This means that a carriage return or linefeed must be appended to the chars string itself if one needs to be sent.

If the process named by the parameter namespec is not known by Supervisor, a fault BAD_NAME is raised.

If the process is not running or is being killed, a fault NOT_RUNNING is raised.