On Thu 19 Feb 2009, cr...@animalhead.com wrote:
> Is there anything a mod_perl2 child_init phase can do to call
> attention to a problem?
>
> I moved a block of code from a post_config handler to a new
> child_init handler, without thinking much about the niceties of the
> move.  The code contained a couple of 'die' statements, which I trust
> would prevent an Apache startup if executed in a post config handler.
>
> Q1: WOULD 'DIE' IN A POST_CONFIG HANDLER ABORT AN
> APACHE2 STARTUP?

yes. Place the following line in your httpd.conf:

PerlPostConfigHandler "sub {die q{huhu>>>>>>>>>>>>>>>>>>>>>>>>}}"

and you'll see something like this in your error log:

[Thu Feb 19 08:51:21 2009] [error] huhu>>>>>>>>>>>>>>>>>>>>>>>> at (eval 
50) line 1.\n
Configuration Failed

and of course no running httpd.

> In the child_init handler, an executed 'die' did nothing noticeable.
> Specifically the message did not end up in the error_log.  In the
> mod_perl2 doc pages, child_init is described as being 'of type void',
> which another page says means that the return value doesn't matter.
>
> I will change the 'die' to a '$s->log_error', and return the
> nastiest- sounding Apache return code I can find, in hopes that some
> future Apache might notice it.
>
> Q2:  IS THERE ANYTHING A CHILD_INIT PHASE CAN DO TO
> ABORT ITS CHILD PROCESS, AND THUS CALL ATTENTION
> TO A SERIOUS PROBLEM?

PerlChildInitHandler "sub {warn q{about to commit suicide}; kill 9, $$}"

or

PerlChildInitHandler "sub {warn q{exiting now}; CORE::exit -1}"

But you should not need that. Because when apache needs another worker 
it will start one (or more). If they exit immediately apache will keep 
starting new ones.

Also, such things are bad for your users experience. The server accepts 
the connection but doesn't respond. The request times out without 
receiving a single byte. I think it's better to serve at least one 
request and inform the user about temporary problems. You can ask the 
current worker to die when the current request is done by 
$r->child_terminate (or was it terminate_child?).

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foert...@gmx.net

Reply via email to