In my work writing mod_wsgi where I do something similar to mod_cgid
and fork off multiple daemon child processes which do special stuff
rather than what the normal Apache child processes do, it occurred to
me that a generic module which could be configured to spawn off
processes, swap user identity and then exec a designated program could
be useful. In other words, one is using Apache as a simple supervisor
to create the daemon processes, monitor them and restart daemon
processes if they die or exit. Apache would also signal such processes
automatically when being shutdown, killing them off if they don't do
so cleanly initially. All this can be very easily done using the
apr_pool_note_subprocess() and apr_proc_other_child_register()
functions in the APR.

I could see this as being a quick way of being able to start up long
running daemon processes for acting as intermediaries in some
messaging system, for memory caching systems (memcached), fastcgi or
scgi like backend processes etc, without the need to worry about
having to come up with different init.d style scripts for different
operating systems and without the need to implement or configure some
distinct process supervisor system.

Now although I thought this might be a quite useful generic module, I
can't seem to find that anyone has written such a thing. Does anyone
know of such a module for Apache? I know that using existing features
of the APR it isn't hard to write. So far I get the impression that
when people need this sort of functionality they possibly tend to
embed it within the specific module they might be implementing rather
than make a generic solution which could be also used to manage
applications not using the APR and Apache APIs.

Anyone got any views on the usefulness of such a thing. If there is
nothing else around I might just hack such a thing up when I get some
time as can see some uses for in stuff I do.

Graham

Reply via email to