You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Q Beukes <ap...@list.za.net> on 2007/07/08 21:21:08 UTC

Apache Service Control

Hey,

I have a question about the design of the service control of Apache in a
Unix environment.

Why is it controlled with signals? When you try and stop Apache a TERM
signal is sent and the process returns. Then the service starts shutting
down. (I bet I just teached you guys something, huh ;>).

To restart the process you need to send a HUP signal. This works fine,
but what if you want to stop the server for a moment and then start it
again, perhaps doing something in the mean while. This cannot be
automated unless you watch the process/PID in some way.

This is fine for most purposes, but what if you want to stop what you're
doing in case the shutdown fails. If the "httpd" binary would return a
non-negative exit code you could know for sure that a failure occured. A
timeout is not so definite. You can send the TERM signal and wait X
amount of seconds, and if the process is still active you stop, but what
if it then finally exits after that?

These are just some issues people have. Some people feel it's a bad
design. Some people (like me) are not so sure what the idea behind it
is. Especially since it's been around since forever - does it have a
good reason for being there and not having changed? I mean Apache has a
pretty good design in general - why would this be any different?

If someone could shed some light on this it would surely ease whats been
bugging me for quite a while.

Thanks,
Q Beukes

Re: Apache Service Control

Posted by Nick Kew <ni...@webthing.com>.
On Sun, 08 Jul 2007 21:21:08 +0200
Q Beukes <ap...@list.za.net> wrote:

> Why is it controlled with signals?

That is customary for daemons.  It works.

> To restart the process you need to send a HUP signal. This works fine,
> but what if you want to stop the server for a moment and then start it
> again, perhaps doing something in the mean while. This cannot be
> automated unless you watch the process/PID in some way.

You could send it SIGKILL and take the consequences.  Not that I'd
recommend that!  There are various techniques you can use for
scripting a shutdown: for example, polling it.

> This is fine for most purposes, but what if you want to stop what
> you're doing in case the shutdown fails. If the "httpd" binary would
> return a non-negative exit code

Return a code to whom?

> These are just some issues people have. Some people feel it's a bad
> design.

Why?

>	 Some people (like me) are not so sure what the idea behind it
> is.

To give the workers time to finish serving current requests rather
than aborting them.

We're open to patches if you have a better design.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/