On 2012-10-22 21:29, Joshua Marantz wrote:
Hi,

Our module has multiple confirmation parameters.  There is a case where if
you have option A and option B, then you must also specify option C,
otherwise Bad things can happen that are a lot easier to debug on startup
than they are after the server is running.

I know how to force 'apachectl' to exit with a nice error message if I
don't like the value of option A or option B.  I can do that in the
function-pointer I provide in my option-table by returning a non-null char*
message.

But in this case I want to exit nicely from the function I have registered
with ap_hook_child_init, having noticed that option A and B are set but not
C.  Is that possible?

By "nicely", I mean that the user types:

% sudo /etc/init.d/apachectl restart
Error in pagespeed.conf: if you have option A and B specified, you must
specify a value for option C.

At that point either the server would not be running, or it would still be
in whatever state it was previously in.

Is this possible?

Currently our solution is to log an error and call abort(), and it's not
very nice!

Don't do it in child_init. I don't think the child can stop the server.

I think apachectl spawns apache with an appropriate -k argument (e.g. "apache2 -k stop") to start/stop/reload apache. However, I don't think that the child has sufficient privileges to stop the parent by exec'ing "apache2 -k stop". Nor can it send the apropriate signal to the parent.

But you can exit nicely in post_config, which is run (as root) after the conf is read but before the children are spawned. It suffices to return a non-ok code for apache to exit. I _think_, I'm not sure, that what you log in post_config does not go on the console but goes to the server log. But maybe there's a way to put the error message on the console too.

Sorin

Reply via email to