Hi Chris/Mike,

Attached is a patch to configuration.xml with some documentation for
fcgi-program section.  Let me know if it needs refinement.

Thanks,

Roger

On Sat, Apr 12, 2008 at 10:50 PM, Roger Hoover <[EMAIL PROTECTED]>
wrote:

> Thanks, Chris.  The unit test coverage for this project is outstanding,
> making it so much easier to make changes.  I learned some new strategies for
> testing by reading your tests.  Great work, guys!
>
> I can create a first pass at the configuration documentation.
>
>
> On Sat, Apr 12, 2008 at 11:39 AM, Chris McDonough <[EMAIL PROTECTED]>
> wrote:
>
> > This is excellent code.
> >
> > I've applied the patch with only a few minor formatting changes to the
> > trunk.
> > Personally, I don't use FastCGI, so I didn't try it in anger, but the
> > patch
> > appears to be inert when you don't use the feature, so I didn't see any
> > reason
> > to not apply it if it works for Roger.
> >
> > We probably need some info in the style of the sections like
> > "[eventlister:x]</code> Section Settings" ala
> >
> > http://svn.supervisord.org/supervisor_manual/trunk/chapters/configuration.xmlto
> > put in the documentation regarding the fcgi-program sections in the
> > config.
> >
> > - C
> >
> >
> > Roger Hoover wrote:
> >
> > > I finally got some time this past weekend do the integration, complete
> > > with
> > > lots of unit tests.  I've got a patch based on the latest svn
> > > revision, 758.
> > >
> > > The configuration for FastCGI programs is the same as regular programs
> > > except an additional "socket" parameter.  Substitution happens on the
> > > socket
> > > parameter with the 'here' and 'program_name' variables.
> > >
> > > [fcgi-program:fcgi_test]
> > > ;socket=tcp://localhost:8002
> > > socket=unix:///path/to/fcgi/socket
> > > ...
> > >
> > > One caveat with this first implementation is that FastCGI programs
> > > must be
> > > homogeneous groups.  It may not be too difficult to lift this
> > > restriction if
> > > you guys think it's a good idea.
> > >
> > > I appreciate whatever feedback you have on this code.  If you're
> > > willing to
> > > accept the patch, I can help with updating the documentation or
> > > whatever
> > > needs to be done.
> > >
> > > Thanks,
> > >
> > > Roger
> > >
> > >
> > > On Sun, Mar 2, 2008 at 1:09 PM, Roger Hoover <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > >  Thanks, Chris.  I understand and was planning on writing thorough
> > > > unit
> > > > tests.
> > > >
> > > >
> > > > On Sun, Mar 2, 2008 at 11:58 AM, Chris McDonough <[EMAIL PROTECTED]>
> > > > wrote:
> > > >
> > > >  Roger Hoover wrote:
> > > > >
> > > > > > Hi Mike and Chris,
> > > > > >
> > > > > > Thanks for the tips.  I wrote a python FastCGI spawner and am
> > > > > > ready to
> > > > > > integrate it into supervisor.  After looking through the code
> > > > > > and
> > > > > >
> > > > > Mike's
> > > > >
> > > > > > tips, I think it will be mostly straightforward.
> > > > > >
> > > > > > Here's what I think I need to do:
> > > > > > - Add PNullDispatcher class to throw away stdin messages
> > > > > > (FastCGI
> > > > > >
> > > > > programs
> > > > >
> > > > > > expect the FastCGI socket to be file descriptor 0 so supervisor
> > > > > > pipe
> > > > > >
> > > > > to
> > > > >
> > > > > > stdin)
> > > > > > - Add FastCGIConfig class
> > > > > > - Add FastCGISubProcess class
> > > > > >    - refactor _spawn method in existing Subprocess class to use
> > > > > > a
> > > > > > _prepare_child_fds() method
> > > > > >    - override _prepare_child_fds() to do FastCGI stuff
> > > > > > - Add FCGIGroupConfig to parse fcgi-program section
> > > > > >
> > > > > > I'm new to python so I'm wondering how to get setup to run the
> > > > > >
> > > > > existing
> > > > >
> > > > > > tests.  I checked the code out of svn but can't get the tests to
> > > > > > run.
> > > > > >
> > > > >  Do I
> > > > >
> > > > > > need to run an easy_install command of some kind?
> > > > > >
> > > > > In the checkout, you can do "python setup.py test" to run the
> > > > > tests (at
> > > > > least on
> > > > > any Internet-connected system).  Note that supervisor is meant to
> > > > > be
> > > > > compatible
> > > > > with all of Python 2.3, 2.4, and 2.5, so using any of those
> > > > > versions of
> > > > > python
> > > > > to do that, the tests should pass.
> > > > >
> > > > > FTR, before you do much work on the integration, I'll offer a
> > > > > warning:
> > > > > this
> > > > > stuff will need to have good test coverage before we can consider
> > > > > putting it in.
> > > > >  Often writing the tests is far more time-consuming than writing
> > > > > the
> > > > > code (or
> > > > > it is for me), so please add this into your time calculations when
> > > > > coming to a
> > > > > decision about whether you want to go ahead with the integration
> > > > > or not.
> > > > >
> > > > > Thanks!
> > > > >
> > > > > - C
> > > > >
> > > > >
> > > >
> >
> >
>
Index: configuration.xml
===================================================================
--- configuration.xml   (revision 761)
+++ configuration.xml   (working copy)
@@ -1244,8 +1244,108 @@
 
   </sect2>
 
+  <sect2 id="fcgi-programx">
+    <title><code>[fcgi-program:x]</code> Section Settings</title>
+
+    <para>
+      Supervisor can manage groups of
+      <ulink url="http://www.fastcgi.com";>FastCGI</ulink> processes that all
+      listen on the same socket.  Until now, deployment flexibility
+      for FastCGI was limited.  To get full process management,
+      you could use mod_fastcgi under Apache but then you were stuck
+      with Apache's inefficient concurrency model of one process
+      or thread per connection.  In addition to requiring more CPU
+      and memory resources, the process/thread per connection model
+      can be quickly saturated by a slow resource, preventing other
+      resources from being served.  In order to take advantage of
+      newer event-driven web servers such as lighttpd or nginx which
+      don't include a built-in process manager, you had to use scripts
+      like cgi-fcgi or spawn-fcgi.  These can be used in conjunction
+      with a process manager such as supervisord or daemontools but
+      require each FastCGI child process to bind to it's own socket.
+      The disadvantages of this are: unnecessarily complicated web
+      server configuration, ungraceful restarts, and reduced fault
+      tolerance.  With less sockets to configure, web server configurations
+      are much smaller if groups of FastCGI processes can share sockets.
+      Shared sockets allow for graceful restarts because the socket remains
+      bound by the parent process while any of the child processes are being
+      restarted.  Finally, shared sockets are more fault tolerant because
+      if a given process fails, other processes can continue to serve
+      inbound connections.
+    </para>
+               
+    <para>
+      With integrated FastCGI spawning support, supervisor gives you the
+      best of both worlds.  You get full-featured process management with
+      groups of FastCGI processes sharing sockets without being tied to a
+      particular web server.  It's a clean separation of concerns, allowing
+      the web server and the process manager to each do what they do best.
+    </para>
+
+    <para>
+      Note that all the options available to <code>[program:x]</code>
+      sections are also respected by fcgi-program sections.
+    </para>
+      
+    <para>
+      <code>[fcgi-program:x]</code> sections have a single key which
+      <code>[program:x]</code> sections do not have.
+    </para>
+
+    <variablelist>
+      <varlistentry>
+        <term>socket</term>
+        <listitem>
+          <para>
+            The FastCGI socket for this program, either TCP or UNIX domain
+            socket. For TCP sockets, use this format: 
+            <code>tcp://localhost:9002</code>.  For UNIX domain sockets, use
+            <code>unix:///absolute/path/to/file.sock</code>.  String
+            expressions are evaluated against a dictionary containing the keys
+            "program_name" and "here" (the directory of the supervisord config
+            file).
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>
+      Consult <code>[program:x]</code> Section Values for allowable
+      keys, delta the above constraints and additions.
+    </para>
+
+    <example>
+      <title><code>[fcgi-program:x]</code> Section Example</title>
+      <programlisting>
+[fcgi-program:fcgiprogramname]
+command=/usr/bin/example.fcgi
+socket=unix:///var/run/supervisor/%(program_name)s.sock
+process_name=%(program_name)s_%(process_num)02d
+numprocs=5
+priority=999
+autostart=true
+autorestart=unexpected
+startsecs=1
+startretries=3
+exitcodes=0,2
+stopsignal=QUIT
+stopwaitsecs=10
+user=chrism
+redirect_stderr=true
+stdout_logfile=/a/path
+stdout_logfile_maxbytes=1MB
+stdout_logfile_backups=10
+stderr_logfile=/a/path
+stderr_logfile_maxbytes=1MB
+stderr_logfile_backups
+environment=A=1,B=2
+      </programlisting>
+    </example>
+
+  </sect2>
+
   <sect2 id="eventlistenerx">
-    <title><code>[eventlister:x]</code> Section Settings</title>
+    <title><code>[eventlistener:x]</code> Section Settings</title>
 
     <para>
       Supervisor allows specialized homogeneous process groups ("event
_______________________________________________
Supervisor-users mailing list
Supervisor-users@lists.supervisord.org
http://lists.supervisord.org/mailman/listinfo/supervisor-users

Reply via email to