Supervisor Process Management Substrate
ObjSupervisor is a concrete implementation of the ObjSubstrate base class that treats processes managed by supervisord as instances. It uses the standard xmlrpc.client library to communicate with the XML-RPC API of a running supervisord instance.
This class abstracts Supervisor's process management into the unified ObjSubstrate interface, allowing you to start, stop, and monitor supervised processes in the same way you would manage VMs or containers.
ObjSupervisor requires the URL of the supervisord XML-RPC interface to be configured in config.yaml.
config.yaml Example:
supervisor:
# URL for the supervisord XML-RPC interface
url: "http://localhost:9001/RPC2"
If no URL is provided, it defaults to http://localhost:9001/RPC2.
ObjSupervisor provides concrete implementations for the core methods in ObjSubstrate.
| Method | Supervisor Implementation Details |
|---|---|
connect() |
Initializes an xmlrpc.client.ServerProxy with the URL from config.yaml and verifies the connection by getting the Supervisor's PID. |
list_instances() |
Lists all processes known to Supervisor, returning their name, group, status, PID, and description. |
get_instance(name) |
Retrieves detailed information for a specific process, including its start/stop times. |
start_instance(name) |
Starts a stopped process. |
stop_instance(name, force) |
Stops a running process. The force parameter controls the wait flag in Supervisor's stopProcess call (if force=True, the call does not wait for the process to fully stop). |
restart_instance(name) |
Overrides the default implementation to use Supervisor's more efficient restart mechanism (a stop followed by a start). |
create_instance(config) |
Not Implemented. This method returns an error. Managing process configurations should be done by editing Supervisor's configuration files and reloading it. |
delete_instance(name, force) |
Not Implemented. This method returns an error. |
execute_command(name, command) |
Not Implemented. This method returns an error, as you cannot execute arbitrary commands within a running process through Supervisor. |
ObjSupervisor.py includes a CLI for managing supervised processes.
listLists all processes and their current status.
python3 factory.deploy/ObjSupervisor.py list
statusGets detailed information for a specific process.
python3 factory.deploy/ObjSupervisor.py status <process-name>
startStarts a specified process.
python3 factory.deploy/ObjSupervisor.py start <process-name>
stopStops a specified process.
python3 factory.deploy/ObjSupervisor.py stop <process-name>
restartRestarts a specified process.
python3 factory.deploy/ObjSupervisor.py restart <process-name>