Process Control

class supervisor.rpcinterface.SupervisorNamespaceRPCInterface(supervisord)
getProcessInfo(name)

Get info about a process named name

@param string name The name of the process (or ‘group:name’)@return struct result A structure containing data about the process

The return value is a struct:

  1. {'name': 'process name', 'group': 'group name', 'description': 'pid 18806, uptime 0:03:12' 'start': 1200361776, 'stop': 0, 'now': 1200361812, 'state': 20, 'statename': 'RUNNING', 'spawnerr': '', 'exitstatus': 0, 'logfile': '/path/to/stdout-log', # deprecated, b/c only 'stdout_logfile': '/path/to/stdout-log', 'stderr_logfile': '/path/to/stderr-log', 'pid': 1}
name

Name of the process

group

Name of the process’ group

description

If process state is running description’s value is process_idand uptime. Example “pid 18806, uptime 0:03:12 ”.If process state is stopped description’s value is stop time.Example:”Jun 5 03:16 PM ”.

start

UNIX timestamp of when the process was started

stop

UNIX timestamp of when the process last ended, or 0 if the processhas never been stopped.

now

UNIX timestamp of the current time, which can be used to calculateprocess up-time.

state

State code, see Process States.

statename

String description of state, see Process States.

logfile

Deprecated alias for stdout_logfile. This is provided onlyfor compatibility with clients written for Supervisor 2.x andmay be removed in the future. Use stdout_logfile instead.

stdout_logfile

Absolute path and filename to the STDOUT logfile

stderr_logfile

Absolute path and filename to the STDOUT logfile

spawnerr

Description of error that occurred during spawn, or empty stringif none.

exitstatus

Exit status (errorlevel) of process, or 0 if the process is stillrunning.

pid

UNIX process ID (PID) of the process, or 0 if the process is notrunning.

getAllProcessInfo()

Get info about all processes

@return array result An array of process status results

Each element contains a struct, and this struct contains the exactsame elements as the struct returned by getProcessInfo. If the processtable is empty, an empty array is returned.

startProcess(name, wait=True)

Start a process

@param string name Process name (or group:name, or group:*)@param boolean wait Wait for process to be fully started@return boolean result Always true unless error

startAllProcesses(wait=True)

Start all processes listed in the configuration file

@param boolean wait Wait for each process to be fully started@return array result An array of process status info structs

startProcessGroup(name, wait=True)

Start all processes in the group named ‘name’

@param string name The group name@param boolean wait Wait for each process to be fully started@return array result An array of process status info structs

stopProcess(name, wait=True)

Stop a process named by name

@param string name The name of the process to stop (or ‘group:name’)@param boolean wait Wait for the process to be fully stopped@return boolean result Always return True unless error

stopProcessGroup(name, wait=True)

Stop all processes in the process group named ‘name’

@param string name The group name@param boolean wait Wait for each process to be fully stopped@return array result An array of process status info structs

stopAllProcesses(wait=True)

Stop all processes in the process list

@param boolean wait Wait for each process to be fully stopped@return array result An array of process status info structs

signalProcess(name, signal)

Send an arbitrary UNIX signal to the process named by name

@param string name Name of the process to signal (or ‘group:name’)@param string signal Signal to send, as name (‘HUP’) or number (‘1’)@return boolean

signalProcessGroup(name, signal)

Send a signal to all processes in the group named ‘name’

@param string name The group name@param string signal Signal to send, as name (‘HUP’) or number (‘1’)@return array

signalAllProcesses(signal)

Send a signal to all processes in the process list

@param string signal Signal to send, as name (‘HUP’) or number (‘1’)@return array An array of process status info structs

sendProcessStdin(name, chars)

Send a string of chars to the stdin of the process name.If non-7-bit data is sent (unicode), it is encoded to utf-8before being sent to the process’ stdin. If chars is not astring or is not unicode, raise INCORRECT_PARAMETERS. If theprocess is not running, raise NOT_RUNNING. If the process’stdin cannot accept input (e.g. it was closed by the childprocess), raise NO_FILE.

@param string name The process name to send to (or ‘group:name’)@param string chars The character data to send to the process@return boolean result Always return True unless error

sendRemoteCommEvent(type, data)

Send an event that will be received by event listenersubprocesses subscribing to the RemoteCommunicationEvent.

@param string type String for the “type” key in the event header@param string data Data for the event body@return boolean Always return True unless error

reloadConfig()

Reload the configuration.

The result contains three arrays containing names of processgroups:

  • added gives the process groups that have been added
  • changed gives the process groups whose contents havechanged
  • removed gives the process groups that are no longerin the configuration

@return array result [[added, changed, removed]]

addProcessGroup(name)

Update the config for a running process from config file.

@param string name name of process group to add@return boolean result true if successful

removeProcessGroup(name)

Remove a stopped process from the active configuration.

@param string name name of process group to remove@return boolean result Indicates whether the removal was successful