Ver código fonte

Move the XML-RPC examples into the XML-RPC section. Fixes #104.

Mike Naberezny 12 anos atrás
pai
commit
4788e8c117
2 arquivos alterados com 90 adições e 85 exclusões
  1. 89 45
      docs/api.rst
  2. 1 40
      docs/introduction.rst

+ 89 - 45
docs/api.rst

@@ -1,6 +1,50 @@
+.. _xml_rpc:
+
 XML-RPC API Documentation
 XML-RPC API Documentation
 =========================
 =========================
 
 
+To use the XML-RPC interface, connect to supervisor's HTTP port
+with any XML-RPC client library and run commands against it.  An
+example of doing this using Python's ``xmlrpclib`` client library
+is as follows.
+
+.. code-block:: python
+
+    import xmlrpclib
+    server = xmlrpclib.Server('http://localhost:9001/RPC2')
+
+You may call methods against :program:`supervisord` and its
+subprocesses by using the ``supervisor`` namespace.  An example is
+provided below.
+
+.. code-block:: python
+
+    server.supervisor.getState()
+
+You can get a list of methods supported by the
+:program:`supervisord` XML-RPC interface by using the XML-RPC
+``system.listMethods`` API:
+
+.. code-block:: python
+
+    server.system.listMethods()
+
+You can see help on a method by using the ``system.methodHelp`` API
+against the method:
+
+.. code-block:: python
+
+    server.system.methodHelp('supervisor.shutdown')
+
+The :program:`supervisord` XML-RPC interface also supports the
+`XML-RPC multicall API
+<http://web.archive.org/web/20060824100531/http://www.xmlrpc.com/discuss/msgReader$1208>`_.
+
+You can extend :program:`supervisord` functionality with new XML-RPC
+API methods by adding new top-level RPC interfaces as necessary.
+See :ref:`rpcinterface_factories`.
+
+
 .. automodule:: supervisor.rpcinterface
 .. automodule:: supervisor.rpcinterface
 
 
 Status and Control
 Status and Control
@@ -37,7 +81,7 @@ Status and Control
         The identification is a string that must be set in Supervisor’s
         The identification is a string that must be set in Supervisor’s
         configuration file. This method simply returns that value back to the
         configuration file. This method simply returns that value back to the
         client.
         client.
-        
+
     .. automethod:: getState
     .. automethod:: getState
 
 
         This is an internal value maintained by Supervisor that determines what
         This is an internal value maintained by Supervisor that determines what
@@ -53,14 +97,14 @@ Status and Control
         methods it intends to call will be permitted.
         methods it intends to call will be permitted.
 
 
         The return value is a struct:
         The return value is a struct:
-                                
+
         .. code-block:: python
         .. code-block:: python
 
 
-            {'statecode': 1, 
+            {'statecode': 1,
              'statename': 'RUNNING'}
              'statename': 'RUNNING'}
 
 
         The possible return values are:
         The possible return values are:
-        
+
         +---------+----------+----------------------------------------------+
         +---------+----------+----------------------------------------------+
         |statecode|statename |Description                                   |
         |statecode|statename |Description                                   |
         +=========+==========+==============================================+
         +=========+==========+==============================================+
@@ -71,7 +115,7 @@ Status and Control
         | 0       |RESTARTING|Supervisor is in the process of restarting.   |
         | 0       |RESTARTING|Supervisor is in the process of restarting.   |
         +---------+----------+----------------------------------------------+
         +---------+----------+----------------------------------------------+
         | -1      |SHUTDOWN  |Supervisor is in the process of shutting down.|
         | -1      |SHUTDOWN  |Supervisor is in the process of shutting down.|
-        +---------+----------+----------------------------------------------+                  
+        +---------+----------+----------------------------------------------+
 
 
         The ``FATAL`` state reports unrecoverable errors, such as internal
         The ``FATAL`` state reports unrecoverable errors, such as internal
         errors inside Supervisor or system runaway conditions. Once set to
         errors inside Supervisor or system runaway conditions. Once set to
@@ -86,13 +130,13 @@ Status and Control
         ignored and their possible return values are undefined.
         ignored and their possible return values are undefined.
 
 
     .. automethod:: getPID
     .. automethod:: getPID
-    
+
     .. automethod:: readLog
     .. automethod:: readLog
 
 
         It can either return the entire log, a number of characters from the
         It can either return the entire log, a number of characters from the
         tail of the log, or a slice of the log specified by the offset and
         tail of the log, or a slice of the log specified by the offset and
         length parameters:
         length parameters:
-        
+
         +--------+---------+------------------------------------------------+
         +--------+---------+------------------------------------------------+
         | Offset | Length  | Behavior of ``readProcessLog``                 |
         | Offset | Length  | Behavior of ``readProcessLog``                 |
         +========+=========+================================================+
         +========+=========+================================================+
@@ -105,15 +149,15 @@ Status and Control
         |        |         | = 0, then the last four characters will be     |
         |        |         | = 0, then the last four characters will be     |
         |        |         | returned from the end of the log.              |
         |        |         | returned from the end of the log.              |
         +--------+---------+------------------------------------------------+
         +--------+---------+------------------------------------------------+
-        |Zero or |Negative | Bad arguments. This will raise the fault       |     
+        |Zero or |Negative | Bad arguments. This will raise the fault       |
         |Positive|         | ``BAD_ARGUMENTS``.                             |
         |Positive|         | ``BAD_ARGUMENTS``.                             |
         +--------+---------+------------------------------------------------+
         +--------+---------+------------------------------------------------+
-        |Zero or |Zero     | All characters will be returned from the       | 
+        |Zero or |Zero     | All characters will be returned from the       |
         |Positive|         | ``offset`` specified.                          |
         |Positive|         | ``offset`` specified.                          |
         +--------+---------+------------------------------------------------+
         +--------+---------+------------------------------------------------+
-        |Zero or |Positive | A number of characters length will be returned | 
+        |Zero or |Positive | A number of characters length will be returned |
         |Positive|         | from the ``offset``.                           |
         |Positive|         | from the ``offset``.                           |
-        +--------+---------+------------------------------------------------+                                    
+        +--------+---------+------------------------------------------------+
 
 
         If the log is empty and the entire log is requested, an empty string
         If the log is empty and the entire log is requested, an empty string
         is returned.
         is returned.
@@ -132,13 +176,13 @@ Status and Control
           readMainLog() is deprecated and support will be dropped from
           readMainLog() is deprecated and support will be dropped from
           Supervisor in a future version.
           Supervisor in a future version.
 
 
-    
+
     .. automethod:: clearLog
     .. automethod:: clearLog
 
 
         If the log cannot be cleared because the log file does not exist, the
         If the log cannot be cleared because the log file does not exist, the
         fault ``NO_FILE`` will be raised. If the log cannot be cleared for any
         fault ``NO_FILE`` will be raised. If the log cannot be cleared for any
         other reason, the fault ``FAILED`` will be raised.
         other reason, the fault ``FAILED`` will be raised.
-    
+
     .. automethod:: shutdown
     .. automethod:: shutdown
 
 
         This method shuts down the Supervisor daemon. If any processes are running,
         This method shuts down the Supervisor daemon. If any processes are running,
@@ -146,7 +190,7 @@ Status and Control
 
 
         Unlike most other methods, if Supervisor is in the ``FATAL`` state,
         Unlike most other methods, if Supervisor is in the ``FATAL`` state,
         this method will still function.
         this method will still function.
-    
+
     .. automethod:: restart
     .. automethod:: restart
 
 
         This method soft restarts the Supervisor daemon. If any processes are
         This method soft restarts the Supervisor daemon. If any processes are
@@ -158,7 +202,7 @@ Status and Control
         Unlike most other methods, if Supervisor is in the ``FATAL`` state,
         Unlike most other methods, if Supervisor is in the ``FATAL`` state,
         this method will still function.
         this method will still function.
 
 
-  
+
 Process Control
 Process Control
 ---------------
 ---------------
 
 
@@ -167,12 +211,12 @@ Process Control
     .. automethod:: getProcessInfo
     .. automethod:: getProcessInfo
 
 
         The return value is a struct:
         The return value is a struct:
-        
+
         .. code-block:: python
         .. code-block:: python
 
 
-            {'name':           'process name',          
-             'group':          'group name',            
-             'start':          1200361776,              
+            {'name':           'process name',
+             'group':          'group name',
+             'start':          1200361776,
              'stop':           0,
              'stop':           0,
              'now':            1200361812,
              'now':            1200361812,
              'state':          1,
              'state':          1,
@@ -182,47 +226,47 @@ Process Control
              'stdout_logfile': '/path/to/stdout-log',
              'stdout_logfile': '/path/to/stdout-log',
              'stderr_logfile': '/path/to/stderr-log',
              'stderr_logfile': '/path/to/stderr-log',
              'pid':            1}
              'pid':            1}
-        
+
         .. describe:: name
         .. describe:: name
 
 
             Name of the process
             Name of the process
-        
+
         .. describe:: group
         .. describe:: group
-              
+
             Name of the process' group
             Name of the process' group
-        
+
         .. describe:: start
         .. describe:: start
-        
+
             UNIX timestamp of when the process was started
             UNIX timestamp of when the process was started
-           
+
         .. describe:: stop
         .. describe:: stop
-        
+
             UNIX timestamp of when the process ended, or 0 if the process is
             UNIX timestamp of when the process ended, or 0 if the process is
             still running.
             still running.
 
 
         .. describe:: now
         .. describe:: now
-        
+
             UNIX timestamp of the current time, which can be used to calculate
             UNIX timestamp of the current time, which can be used to calculate
             process up-time.
             process up-time.
-        
+
         .. describe:: state
         .. describe:: state
-            
+
             State code, see table below.
             State code, see table below.
-        
+
         .. describe:: statename
         .. describe:: statename
-        
+
             String description of `state`, see table below.
             String description of `state`, see table below.
-            
+
         .. describe:: stdout_logfile
         .. describe:: stdout_logfile
-        
+
             Absolute path and filename to the STDOUT logfile
             Absolute path and filename to the STDOUT logfile
 
 
         .. describe:: stderr_logfile
         .. describe:: stderr_logfile
-        
+
             Absolute path and filename to the STDOUT logfile
             Absolute path and filename to the STDOUT logfile
 
 
         .. describe:: spawnerr
         .. describe:: spawnerr
-        
+
             Description of error that occurred during spawn, or empty string
             Description of error that occurred during spawn, or empty string
             if none.
             if none.
 
 
@@ -236,27 +280,27 @@ Process Control
             UNIX process ID (PID) of the process, or 0 if the process is not
             UNIX process ID (PID) of the process, or 0 if the process is not
             running.
             running.
 
 
-    
+
     .. automethod:: getAllProcessInfo
     .. automethod:: getAllProcessInfo
 
 
         Each element contains a struct, and this struct contains the exact
         Each element contains a struct, and this struct contains the exact
         same elements as the struct returned by ``getProcess``. If the process
         same elements as the struct returned by ``getProcess``. If the process
         table is empty, an empty array is returned.
         table is empty, an empty array is returned.
-    
+
     .. automethod:: startProcess
     .. automethod:: startProcess
-    
+
     .. automethod:: startAllProcesses
     .. automethod:: startAllProcesses
-    
+
     .. automethod:: startProcessGroup
     .. automethod:: startProcessGroup
-    
+
     .. automethod:: stopProcessGroup
     .. automethod:: stopProcessGroup
-    
+
     .. automethod:: sendProcessStdin
     .. automethod:: sendProcessStdin
-    
+
     .. automethod:: sendRemoteCommEvent
     .. automethod:: sendRemoteCommEvent
-    
+
     .. automethod:: addProcessGroup
     .. automethod:: addProcessGroup
-    
+
     .. automethod:: removeProcessGroup
     .. automethod:: removeProcessGroup
 
 
 Process Logging
 Process Logging
@@ -291,4 +335,4 @@ System Methods
     .. automethod:: methodSignature
     .. automethod:: methodSignature
 
 
     .. automethod:: multicall
     .. automethod:: multicall
-                    
+

+ 1 - 40
docs/introduction.rst

@@ -157,46 +157,7 @@ XML-RPC Interface
 
 
   The same HTTP server which serves the web UI serves up an XML-RPC
   The same HTTP server which serves the web UI serves up an XML-RPC
   interface that can be used to interrogate and control supervisor and
   interface that can be used to interrogate and control supervisor and
-  the programs it runs.  To use the XML-RPC interface, connect to
-  supervisor's http port with any XML-RPC client library and run
-  commands against it.  An example of doing this using Python's
-  ``xmlrpclib`` client library is as follows.
-
-  .. code-block:: python
-
-     import xmlrpclib
-     server = xmlrpclib.Server('http://localhost:9001/RPC2')
-
-  You may call methods against the :program:`supervisord` and its
-  subprocesses by using the ``supervisor`` namespace.  An example is
-  provided below.
-
-  .. code-block:: python
-
-     server.supervisor.getState()
-
-  You can get a list of methods supported by the
-  :program:`supervisord` XML-RPC interface by using the XML-RPC
-  ``system.listMethods`` API:
-
-  .. code-block:: python
-
-     server.system.listMethods()
-
-  You can see help on a method by using the ``system.methodHelp`` API
-  against the method:
-
-  .. code-block:: python
-
-     print server.system.methodHelp('supervisor.shutdown')
-
-  The :program:`supervisord` XML-RPC interface also supports the
-  nascent `XML-RPC multicall API
-  <http://www.xmlrpc.com/discuss/msgReader$1208>`_.
-
-  You can extend :program:`supervisord` functionality with new XML-RPC
-  API methods by adding new top-level RPC interfaces as necessary.
-  See :ref:`rpcinterface_factories`.
+  the programs it runs.  See :ref:`xml_rpc`.
 
 
 Platform Requirements
 Platform Requirements
 ---------------------
 ---------------------