ganeshk has asked for the wisdom of the Perl Monks concerning the following question:

I run apache(1.3)/mod_perl in Linux and there are a couple of child processes. I understand that whenever a HTTP request comes, it is for apache to decide which child process should handle it. But in certain events I would want to do change the state of all the currently running apache child processes. This could be things like changing or resetting some flags, reloading configuration files or even reloading the perl modules themselves. Is there anyway for exercising some extra control like this on the apache processes? As far as I know I think we can't do this via HTTP. But please tell me even if you can achieve this via HTTP requests itself.

Thanks in advance!

Thanks, Ganesh

Replies are listed 'Best First'.
Re: Control over apache processes
by pjotrik (Friar) on Aug 19, 2008 at 13:01 UTC
Re: Control over apache processes
by perrin (Chancellor) on Aug 19, 2008 at 16:23 UTC
    In addition to Apache::Reload, you can do this sort of thing by having your processes check periodically to see if your configuration file has changed. Just keep the last mtime of the file in a global and check if it's been updated since then, possibly in an early phase like PerlFixupHandler. If stat-ing the file makes you worry about performance, you can keep a last-checked time as well and only check it every 30 seconds.

      In addition to Apache::Reload, you can do this sort of thing by having your processes check periodically to see if your configuration file has changed.

      Perrin, is it possible to make an Apache process(under mod_perl) do something like this? Basically if we try to achieve this by posting HTTP requests you never know if all the processes will be affected. Correct? So how would you make this periodic polling? Thanks very much for the replies.

      Thanks,
      Ganesh

        Yes, mod_perl is what I'm talking about here (although you could do something similar in any persistent environment). You don't need to contact all processes at once -- you just need them to check for this when they do get a request. In other words, make all of your processes check at the beginning of any new request for a change in their environment and take action if they discover one.
Re: External control over apache processes
by Anonymous Monk on Aug 19, 2008 at 12:29 UTC