Extending Supervisor’s XML-RPC API
Supervisor can be extended with new XML-RPC APIs. Several third-partyplugins already exist that can be wired into your Supervisorconfiguration. You may additionally write your own. ExtensibleXML-RPC interfaces is an advanced feature, introduced in version 3.0.You needn’t understand it unless you wish to use an existingthird-party RPC interface plugin or if you wish to write your own RPCinterface plugin.
Configuring XML-RPC Interface Factories
An additional RPC interface is configured into a supervisorinstallation by adding a [rpcinterface:x] section in theSupervisor configuration file.
In the sample config file, there is a section which is named[rpcinterface:supervisor]. By default it looks like this:
- [rpcinterface:supervisor]
- supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
This section must remain in the configuration for the standard setupof supervisor to work properly. If you don’t want supervisor to doanything it doesn’t already do out of the box, this is all you need toknow about this type of section.
However, if you wish to add additional XML-RPC interface namespaces toa configuration of supervisor, you may add additional[rpcinterface:foo] sections, where “foo” represents the namespaceof the interface (from the web root), and the value named bysupervisor.rpcinterface_factory is a factory callable written inPython which should have a function signature that accepts a singlepositional argument supervisord and as many keyword arguments asrequired to perform configuration. Any key/value pairs defined withinthe rpcinterface:foo section will be passed as keyword argumentsto the factory. Here’s an example of a factory function, created inthe package my.package.
- def make_another_rpcinterface(supervisord, **config):
- retries = int(config.get('retries', 0))
- another_rpc_interface = AnotherRPCInterface(supervisord, retries)
- return another_rpc_interface
And a section in the config file meant to configure it.
- [rpcinterface:another]
- supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
- retries = 1