2.2. Process Control

2.2.1. supervisor.getProcessInfo()

supervisor.getProcessInfo(namespec)

Table 2.21. supervisor.getProcessInfo() Parameters

Type Name Description
string namespec Name of the group and process

Table 2.22. 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.23. supervisor.getAllProcessInfo() Parameters

Type Name Description

Table 2.24. 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.25. 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.26. 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.startAllProcesses()

supervisor.startAllProcesses()

Table 2.27. supervisor.startAllProcesses() Parameters

Type Name Description
boolean wait Wait for start to complete before returning? (optional, default True)

Table 2.28. supervisor.startAllProcesses() Return Value

Type Description
boolean or array<struct> See below

This method will start all processes that are not running. It is the equivalent of calling supervisor.startProcess() on every process that is not running.

If wait=False, the method will return immediately without waiting for Supervisor to start any of the processes in the group. The return value will always be boolean True.

If wait=True, Supervisor will attempt to start every process in the group. It will then hold the HTTP request until each process has reached startsecs.

The return value will then be an array of structs, where each struct contains the keys group (group name), name (process name), description (process description), and status (fault code).

If a process starts successfully, the status will be set to SUCCESS. Otherwise, the fault ABNORMAL_TERMINATION is raised.

2.2.5. supervisor.startProcessGroup()

supervisor.startProcessGroup(name, wait=True)

Table 2.29. supervisor.startProcessGroup() Parameters

Type Name Description
string name Name of the group
boolean wait Wait for start to complete before returning? (optional, default True)

Table 2.30. supervisor.startProcessGroup() Return Value

Type Description
boolean or array<struct> See below

The supervisor.startProcessGroup() method will start all processes in a group. If name of the group (name 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 any of the processes in the group. The return value will always be boolean True.

If wait=True, Supervisor will attempt to start every process in the group. It will then hold the HTTP request until each process has reached startsecs.

The return value will then be an array of structs, where each struct contains the keys group (group name), name (process name), description (process description), and status (fault code).

If a process starts successfully, the status will be set to SUCCESS. Otherwise, the fault ABNORMAL_TERMINATION is raised.

2.2.6. supervisor.stopProcessGroup()

supervisor.stopProcessGroup(name)

Table 2.31. supervisor.stopProcessGroup() Parameters

Type Name Description
string name Group name to stop
boolean wait Wait for stop to complete before returning? (optional, default True)

Table 2.32. supervisor.stopProcessGroup() Return Value

Type Description
boolean or array<struct> See below

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 wait=True, Supervisor hold the HTTP request until each process has been stopped (or tries to stop have been exhausted).

The return value will then be an array of structs, where each struct contains the keys group (group name), name (process name), description (process description), and status (fault code).

If any process cannot be stopped then the fault code for FAILED will be reported in its return struct. This is abnormal and results in Supervisor being in a potentially unstable condition.

If wait=False, the method will return immediately without waiting for Supervisor to stop any of the processes. The return value will always be boolean True.

2.2.7. supervisor.stopProcess()

supervisor.stopProcess(namespec)

Table 2.33. supervisor.stopProcess() Parameters

Type Name Description
string namespec Name of the group and process

Table 2.34. 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.8. supervisor.stopAllProcesses()

supervisor.stopAllProcesses()

Table 2.35. supervisor.stopAllProcesses() Parameters

Type Name Description
boolean wait Wait for stop to complete before returning? (optional, default True)

Table 2.36. supervisor.stopAllProcesses() Return Value

Type Description
boolean or array<struct> See below

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

If wait=True, Supervisor hold the HTTP request until each process has been stopped (or tries to stop have been exhausted).

The return value will then be an array of structs, where each struct contains the keys group (group name), name (process name), description (process description), and status (fault code).

If any process cannot be stopped then the fault code for FAILED will be reported in its return struct. This is abnormal and results in Supervisor being in a potentially unstable condition.

If wait=False, the method will return immediately without waiting for Supervisor to stop any of the processes. The return value will always be boolean True.

2.2.9. supervisor.sendProcessStdin()

supervisor.sendProcessStdin(namespec, chars)

Table 2.37. 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.38. 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.

2.2.10. supervisor.sendRemoteCommEvent() (added in 3.0a7)

supervisor.sendRemoteCommEvent()

Table 2.39. supervisor.sendRemoteCommEvent() Parameters

Type Name Description
string type Value for type in the event header
string data Value for the event payload

Table 2.40. supervisor.sendRemoteCommEvent() Return Value

Type Description
boolean Always TRUE

The supervisor.sendRemoteCommEvent() method emits an event that will be received by event listener subprocesses subscribing to the REMOTE_COMMUNICATION event type.

2.2.11. supervisor.addProcessGroup() (added in 3.0a7)

supervisor.addProcessGroup(namespec)

Table 2.41. supervisor.addProcessGroup() Parameters

Type Name Description
string name Name of the group

Table 2.42. supervisor.addProcessGroup() Return Value

Type Description
boolean Always TRUE

The supervisor.addProcessGroup() reads a process group's config from the supervisord.conf file and adds the process group if it hasn't already been added (or if it has been removed). It automatically starts the process group if it is set to autostart.

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

If the process group is already active, an ALREADY_ADDED is raised.

2.2.12. supervisor.removeProcessGroup() (added in 3.0a7)

supervisor.removeProcessGroup(namespec)

Table 2.43. supervisor.removeProcessGroup() Parameters

Type Name Description
string name Name of the group

Table 2.44. supervisor.removeProcessGroup() Return Value

Type Description
boolean Always TRUE

The supervisor.removeProcess() removes a process group from the supervisord runtime configuration.

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

If the process group is not yet stopped, a STILL_RUNNING is raised.