[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Monit Can't Stop Apache
From: |
Jan-Henrik Haukeland |
Subject: |
Re: Monit Can't Stop Apache |
Date: |
Tue, 1 Mar 2005 03:17:00 +0100 |
On Mar 1, 2005, at 0:03, Chris Lopeman wrote:
Actually I am using Apache 2.0.?.
I belive the prefork model is the default for apache 2.x also. Even the
threaded models forks of a few child processes which will act as
workers with a thread pool. The thing is, (as Martin said) if you do a
kill -9 on the main controlling httpd process, i.e. the one referenced
in the httpd.pid file monit will have problems managing apache. Before
I explain why, I should point out that killing the main apache process
with -9 is not smart and imply that you need to read up on how apache
works :-) The main apache process controls all of its child processes
and is also responsible for gracefully closing them down, which it will
do if you send the main process a TERM signal using e.g. kill *without*
-9. But if you murder the controller as you do with kill -9 it will die
immediately and not get a chance to cleanup. The result is that apache
child processes will continue to run and answer on port 80 (or
whatever), and that's the reason monit cannot start apache again
because a new apache instance cannot bind to port 80. See? And because
there are no controlling process you need to "manually" kill every
running child process before apache can start (and bind to port 80)
again. You can do this by e.g. using "killall -9 httpd" from the shell
to get rid of the stray httpd children.
However, I would assume the same holds true. What you have suggested
is basically to create a custom script to clean up Apache if parts are
still running. But that seems kind of silly to do since "httpd
restart" already does a great job of this. You seem to be implying
that there is something wrong with calling "httpd restart".
What do you mean by calling "httpd restart"? If httpd is the apache
httpd program it does not take no "restart" argument. If it is a
script/program and it really does cleanup any stray httpd children
before starting apache why don't you simply use this in monit's
start-program statement? BTW afaik /etc/init.d/apache at least on my
Unix systems (FC2 and Mac OS X) will have problems starting apache
again if you kill the controlling process and have httpd children
floating around on the system.
Anyway I think I was too subtle. My real questions more general.
Should people setting up monit seriously consider using restart on
each process instead of start?
No
Or should monit trust the stop scripts more and just run them?
No
After all should not they be best at detecting if it is still running
and if anything needs to be cleaned up. Maybe the best of both worlds
is to provided monit with a flag for each stop command that tells it
to force the stop to run or not.
IMHO the best would be to know how your daemon works and write or use
your start and stop program accordingly.
--
Jan-Henrik Haukeland
Mobil +47 97141255