XML-RPC API Documentation¶
To use the XML-RPC interface, first make sure you have configured the interface factory properly by setting the default factory. See Configuring XML-RPC Interface Factories.
Then you can connect to supervisor’s HTTP port with any XML-RPC client library and run commands against it.
An example of doing this using Python 2’s xmlrpclib
client library
is as follows.
import xmlrpclib
server = xmlrpclib.Server('http://localhost:9001/RPC2')
An example of doing this using Python 3’s xmlrpc.client
library
is as follows.
from xmlrpc.client import ServerProxy
server = ServerProxy('http://localhost:9001/RPC2')
You may call methods against supervisord and its
subprocesses by using the supervisor
namespace. An example is
provided below.
server.supervisor.getState()
You can get a list of methods supported by the
supervisord XML-RPC interface by using the XML-RPC
system.listMethods
API:
server.system.listMethods()
You can see help on a method by using the system.methodHelp
API
against the method:
server.system.methodHelp('supervisor.shutdown')
The supervisord XML-RPC interface also supports the XML-RPC multicall API.
You can extend supervisord functionality with new XML-RPC API methods by adding new top-level RPC interfaces as necessary. See Configuring XML-RPC Interface Factories.
Note
Any XML-RPC method call may result in a fault response. This includes errors caused by the client such as bad arguments, and any errors that make supervisord unable to fulfill the request. Many XML-RPC client programs will raise an exception when a fault response is encountered.