You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Mladen Turk <mt...@apache.org> on 2003/09/11 08:38:01 UTC

Hooking child termination

Hi all,

Is there a possibility to add some sort of a hook to a parent that will
execute when the child process dies? I would like to have a config
option that will (something like Windows service manager has for the
services itself) behave differently on first and on the consecutive
failures, either launching sendmail, or shutting down the httpd itself,
or whatever.

What would be the right place to add such a feature; core or mpm?

MT.


RE: Hooking child termination

Posted by Mladen Turk <mt...@apache.org>.

> From: William A. Rowe, Jr.
> >
> >Is there a possibility to add some sort of a hook to a 
> parent that will 
> >execute when the child process dies? I would like to have a config 
> >option that will (something like Windows service manager has for the 
> >services itself) behave differently on first and on the consecutive 
> >failures, either launching sendmail, or shutting down the 
> httpd itself, 
> >or whatever.
> >
> 
> Within the mpm - they way it is determined changes from mpm 
> to mpm. You ask about "the child process" - there may be one, 
> or many.  You will need to decide if this should trigger on 
> each individual child process that "goes away" - perhaps with 
> a useful nugget like that childs' apr_proc_t.
> 

As I see the problem, if the child process exited prematurely then
eventually all of them will at some point.

> But I suggest you take a look at the otherchild logic first.  
> Perhaps we goofed?  Maybe in 2.1 the very best thing would be 
> to treat all worker processes as "just another otherchild"?  
> That seems like it would become alot more extensible.

True. IMO all worker processes should be treated as just one.
If the process (or one of them) dies due to a fatal error, it is just
restarted, meaning that the entire httpd eventually enters in the
launch/exit loop, consuming 100% of cpu.

I was thinking of something like:

ServerOnFatalError 1 restart
ServerOnFatalError 2 /do_something
ServerOnFatalError 3 /do_something
...
ServerOnFatalError n shutdown

First argument is the number of times the worker process has exited with
the fatal error, and the second is the action.
There should also be some sort of the time window when the counter is
reset to 0, like:

ServerFatalErrorTimeout 60


> Again - that logic all belongs in the mpm itself.
> 

Then the logic has to eventually be implemented in each mpm separately?


MT.


Re: Hooking child termination

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 01:38 AM 9/11/2003, Mladen Turk wrote:

>Hi all,
>
>Is there a possibility to add some sort of a hook to a parent that will
>execute when the child process dies? I would like to have a config
>option that will (something like Windows service manager has for the
>services itself) behave differently on first and on the consecutive
>failures, either launching sendmail, or shutting down the httpd itself,
>or whatever.
>
>What would be the right place to add such a feature; core or mpm?

Within the mpm - they way it is determined changes from mpm to mpm.
You ask about "the child process" - there may be one, or many.  You will
need to decide if this should trigger on each individual child process that
"goes away" - perhaps with a useful nugget like that childs' apr_proc_t.

But I suggest you take a look at the otherchild logic first.  Perhaps we
goofed?  Maybe in 2.1 the very best thing would be to treat all worker
processes as "just another otherchild"?  That seems like it would become
alot more extensible.  Again - that logic all belongs in the mpm itself.

Bill