monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monit Can't Stop Apache


From: Chris Lopeman
Subject: Re: Monit Can't Stop Apache
Date: Mon, 28 Feb 2005 20:54:33 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)

Jan-Henrik Haukeland wrote:


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.

Based on what you said above, I really think you are missing the point. The kill -9 is not something I would normally do. It was not meant to be a clean way of exiting apache. It is a simulation of something going wrong. Just the type of thing that Monit is there to handle.

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



--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general








reply via email to

[Prev in Thread] Current Thread [Next in Thread]