xmlrpc.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. .. _rpcinterface_factories:
  11. Configuring XML-RPC Interface Factories
  12. ---------------------------------------
  13. An additional RPC interface is configured into a supervisor
  14. installation by adding a ``[rpcinterface:x]`` section in the
  15. Supervisor configuration file.
  16. In the sample config file, there is a section which is named
  17. ``[rpcinterface:supervisor]``. By default it looks like this:
  18. .. code-block:: ini
  19. [rpcinterface:supervisor]
  20. supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
  21. This section *must* remain in the configuration for the standard setup
  22. of supervisor to work properly. If you don't want supervisor to do
  23. anything it doesn't already do out of the box, this is all you need to
  24. know about this type of section.
  25. However, if you wish to add additional XML-RPC interface namespaces to
  26. a configuration of supervisor, you may add additional
  27. ``[rpcinterface:foo]`` sections, where "foo" represents the namespace
  28. of the interface (from the web root), and the value named by
  29. ``supervisor.rpcinterface_factory`` is a factory callable written in
  30. Python which should have a function signature that accepts a single
  31. positional argument ``supervisord`` and as many keyword arguments as
  32. required to perform configuration. Any key/value pairs defined within
  33. the ``rpcinterface:foo`` section will be passed as keyword arguments
  34. to the factory. Here's an example of a factory function, created in
  35. the package ``my.package``.
  36. .. code-block:: python
  37. def make_another_rpcinterface(supervisord, **config):
  38. retries = int(config.get('retries', 0))
  39. another_rpc_interface = AnotherRPCInterface(supervisord, retries)
  40. return another_rpc_interface
  41. And a section in the config file meant to configure it.
  42. .. code-block:: ini
  43. [rpcinterface:another]
  44. supervisor.rpcinterface_factory = my.package:make_another_rpcinterface
  45. retries = 1