DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Testing Etch out, and i tried to restart my apache2 server, and i noticed it took ages compared to Sarge, so i looked at the init.d script for apache2 and noticed a sleep 10 command, anyone now why it's waiting this long to restart the server? and if i can comment it out?
Typically sleep statements are added to give some process time to run before the next one is run.
So to know the answer to your question would depend on WHERE the sleep is in the script. If its at the very beginning then you'd want to know what init script was running right before it. (Unlikely but just used as an example.) If it is in the body of the script you'd need to figure out what it was doing before the sleep (e.g. is it removing some old file(s), executing a command line to start a process (e.g. httpd) or what? Then what does it do after the sleep.
It's very likely the item after the sleep is dependent on successful completion of the item before the sleep. You may be able to reduce the amount of sleep (e.g. sleep 1) if you know the item before the sleep is actually completing more quickly than 10. You should be sure though - people seldom add sleeps without a reason - 10 seconds isn't really a high cost to pay for being sure your web server starts up correctly.
Of course if you're not running a web server at all you can just disable the start of apache altogether and avoid this.
Usually, when there's a line of code, it's for something. I wouldn't tweak it before understanding exactly what you do.
Anyway, do you restart your apache every hour or what?
I think that the offending code he is talking about is here:
Code:
restart | force-reload)
log_begin_msg "Forcing reload of web server (apache2)..."
if ! apache_stop; then
log_end_msg 1
fi
sleep 10
if $APACHE2CTL start; then
log_end_msg 0
else
log_end_msg 1
fi
;;
That sleep there is to ensure that all of the currently running Apache processes have in fact stopped running. I have seen (with Apache2) that the processes can sometimes take a little while to close up shop properly, so this delay is to make sure that they have in fact closed up shop before they get started again.
If this delay didn't occur, and it tried to start the Apache process before the old one had completed shutting down, things like lock files have a tendency to get in the way and the new process will not start. This can cause havoc if you are trying to restart a live web server and only want it to be down for the minimal amount of time. If you were to restart it only to have it die because there was still a lock file in the way that two seconds later would have been removed. Better to wait the ten seconds and only have that down time than risk not having the service start up again and waste even more time.
it appears to be in the way that the stop section of the code is written.
Code:
apache_stop() {
if `apache2 -t > /dev/null 2>&1`; then
# if the config is ok than we just stop normaly
$APACHE2 -k stop
else
# if we are here something is broken and we need to try
# to exit as nice and clean as possible
...
That first bit there (I am going to ignore the abnormal situation that is mentioned there...) basically sends a signal to the Apache service telling it to shut down. That process then ends immediately and the Apache service takes over. At this point, the init.d script has no idea what is going on with Apache2, so it immediately falls through.
The restart portion of the init.d script then moves on to the starting portion, which would probably break if there were not a time delay.
This is not really a problem with the init script as it is with Apache2 itself.
The real solution would be for Apache2 to have a signal that allows it to re-start cleanly and properly instead of stopping everything and starting fresh.
Typically when you restart Apache2 like this, the reason you are doing so is because you have changed something in a configuration file (such as adding a new virtual site or something like that), so a simple re-reading of the configuration file would be a nice thing, ala postfix.
no, it's just annoying since sarge did not wait that long,
Why start with "no"?
The question was answered by more than one person saying that sleeps are seldom added without a reason. If you don't like the damn sleep then just comment it out and don't bother the rest of us since you're obviously going to ignore the responses you get.
The question was answered by more than one person saying that sleeps are seldom added without a reason. If you don't like the damn sleep then just comment it out and don't bother the rest of us since you're obviously going to ignore the responses you get.
the "no" was the answer to this question: "do you restart your apache every hour or what?"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.