please reproduce: rc.httpd force-restart stops, but does not restart, httpd
SlackwareThis Forum is for the discussion of Slackware 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.
please reproduce: rc.httpd force-restart stops, but does not restart, httpd
The command
# /etc/rc.d/rc.httpd force-restart
does not work for me. It successfully stops all httpd processes, but does not restart them. The output is:
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
I can reliably reproduce the behavior on two different Slackware-64 15.0 nodes by
running pgrep -a httpd (to verify httpd processes are running),
running rc.httpd force-restart, and
running pgrep -a httpd again (to verify the restart failed).
I suspect a timing issue, where httpd is not fully stopped yet when the restart begins. But before I start to work on it, can anyone else confirm this behavior with Slackware-64 15.0?
I've seen this for a long time now. I usually do 'rc.httpd stop' (wait awhile) 'rc.httpd start'. Slackware current. Maybe a 'sleep' command in there would help.
I've seen this for a long time now. I usually do 'rc.httpd stop' (wait awhile) 'rc.httpd start'. Slackware current. Maybe a 'sleep' command in there would help.
Now that you’ve confirmed the behavior, that’s what I’m going to try first.
Quote:
Originally Posted by scuzzy_dog
If you just want to reload .conf files then do
apachectl graceful
You’re right, but the actual use-case is reloading patched executables after a security update. Today it was a patch release of mariadb, which replaced /usr/lib64/libmariadb.so.3, which is linked to by /usr/sbin/httpd. apachectl graceful does not reload executables from disk, so it’s not enough.
I suspect that pwait is the missing bit, and that pkill really shouldn't be used unless the .pid files are missing (they shouldn't be, but I'll avoid removing that fallback anyway).
So, how about this?
Code:
#!/bin/sh
#
# /etc/rc.d/rc.httpd
#
# Start/stop/force-restart/restart/graceful[ly restart]/graceful[ly]-stop
# the Apache (httpd) web server.
#
# To make Apache start automatically at boot, make this
# file executable: chmod 755 /etc/rc.d/rc.httpd
#
# For information on these options, "man apachectl".
case "$1" in
'start')
/usr/sbin/apachectl -k start
;;
'stop')
if [ ! -r /var/run/httpd.pid -a ! -r /var/run/httpd/httpd.pid ]; then
pkill -f /usr/sbin/httpd
else
/usr/sbin/apachectl -k stop
fi
pwait -f /usr/sbin/httpd
;;
'force-restart')
if [ ! -r /var/run/httpd.pid -a ! -r /var/run/httpd/httpd.pid ]; then
pkill -f /usr/sbin/httpd
else
/usr/sbin/apachectl -k stop
fi
pwait -f /usr/sbin/httpd
/usr/sbin/apachectl -k start
;;
'restart')
/usr/sbin/apachectl -k restart
;;
'graceful')
/usr/sbin/apachectl -k graceful
;;
'graceful-stop')
/usr/sbin/apachectl -k graceful-stop
;;
*)
echo "Usage: $0 {start|stop|force-restart|restart|graceful|graceful-stop}"
;;
esac
Yes, and your solution is fine. My first draft actually just changed one word, pkill to pwait, and that worked perfectly for me.
I noticed that the legacy force-restart code seems designed to stop httpd even under unusual circumstances, when apachectl -k stop is ineffective. I have heard of that happening, though not to me. That's why I put back the pkill, behind a one-second grace period. I agree under normal conditions it is, well, overkill.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.