xmlrpc.rst 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Extending Supervisor's XML-RPC API
  2. ==================================
  3. Supervisor can be extended with new XML-RPC APIs. Several third-party
  4. plugins already exist that can be wired into your Supervisor
  5. configuration. You may additionally write your own. Extensible
  6. XML-RPC interfaces is an advanced feature, introduced in version 3.0.
  7. You needn't understand it unless you wish to use an existing
  8. third-party RPC interface plugin or if you wish to write your own RPC
  9. interface plugin.
  10. Configuring XML-RPC Interface Factories
  11. ---------------------------------------
  12. An additional RPC interface is configured into a supervisor
  13. installation by adding a ``[rpcinterface:x]`` section in the
  14. Supervisor configuration file.
  15. In the sample config file, there is a section which is named
  16. ``[rpcinterface:supervisor]``. By default it looks like this:
  17. .. code-block:: ini
  18. [rpcinterface:supervisor]
  19. supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
  20. This section *must* remain in the configuration for the standard setup
  21. of supervisor to work properly. If you don't want supervisor to do
  22. anything it doesn't already do out of the box, this is all you need to
  23. know about this type of section.
  24. However, if you wish to add additional XML-RPC interface namespaces to
  25. a configuration of supervisor, you may add additional
  26. ``[rpcinterface:foo]`` sections, where "foo" represents the namespace
  27. of the interface (from the web root), and the value named by
  28. ``supervisor.rpcinterface_factory`` is a factory callable written in
  29. Python which should have a function signature that accepts a single
  30. positional argument ``supervisord`` and as many keyword arguments as
  31. required to perform configuration. Any key/value pairs defined within
  32. the ``rpcinterface:foo`` section will be passed as keyword arguments
  33. to the factory. Here's an example of a factory function, created in
  34. the package ``my.package``.
  35. .. code-block:: python
  36. def make_another_rpcinterface(supervisord, **config):
  37. retries = int(config.get('retries', 0))
  38. another_rpc_interface = AnotherRPCInterface(supervisord, retries)
  39. return another_rpc_interface
  40. And a section in the config file meant to configure it.
  41. .. code-block:: ini
  42. [rpcinterface:another]
  43. supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
  44. retries = 1