LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-15-2023, 12:11 PM   #1
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 373

Rep: Reputation: 172Reputation: 172
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:
  1. (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
  2. (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
  3. no listening sockets available, shutting down
  4. AH00015: Unable to open logs
I can reliably reproduce the behavior on two different Slackware-64 15.0 nodes by
  1. running pgrep -a httpd (to verify httpd processes are running),
  2. running rc.httpd force-restart, and
  3. 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?
 
Old 08-15-2023, 12:38 PM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 798

Rep: Reputation: 256Reputation: 256Reputation: 256
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.
 
Old 08-15-2023, 02:38 PM   #3
scuzzy_dog
Member
 
Registered: Apr 2021
Location: Free State of Texas (somewhat free)
Posts: 108

Rep: Reputation: Disabled
If you just want to reload .conf files then do

apachectl graceful

That's usually worked for me.

https://httpd.apache.org/docs/2.4/stopping.html
 
Old 08-15-2023, 03:38 PM   #4
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 373

Original Poster
Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by jayjwa View Post
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 View Post
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.

Last edited by metaed; 08-15-2023 at 03:39 PM.
 
Old 08-15-2023, 04:22 PM   #5
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 373

Original Poster
Rep: Reputation: 172Reputation: 172
This patch to /etc/rc.d/rc.httpd solves it for me. Again this is for stock Slackware-64 15.0.

Code:
--- rc.httpd.orig       2021-12-20 18:31:27.000000000 +0000
+++ rc.httpd    2023-08-15 21:18:03.775517444 +0000
@@ -22,10 +22,15 @@
   ;;
   'force-restart')
     # Because sometimes restarting through apachectl just doesn't do the trick...
+    echo stopping httpd nicely
     /usr/sbin/apachectl -k stop
-    pkill -f /usr/sbin/httpd
+    ( sleep 1 ; echo stopping httpd less nicely ; pkill -f /usr/sbin/httpd ) &
+    sleeper=$!
+    pwait -f /usr/sbin/httpd
+    kill -0 $sleeper && kill $sleeper || true
     # Remove both old and new .pid locations:
     rm -f /var/run/httpd.pid /var/run/httpd/httpd.pid
+    echo starting httpd
     /usr/sbin/apachectl -k start
   ;;
   'restart')
 
Old 08-15-2023, 05:39 PM   #6
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,547

Rep: Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555Reputation: 8555
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
 
1 members found this post helpful.
Old 08-15-2023, 06:30 PM   #7
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 373

Original Poster
Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by volkerdi View Post
I suspect that pwait is the missing bit
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.
 
  


Reply

Tags
httpd, slackware 15.0



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I reproduce a WMAL file? iqbala Ubuntu 3 12-17-2008 05:03 PM
MP3 player that reproduce ogg rsottini Linux - Hardware 1 12-12-2008 11:32 AM
to reproduce the command killed with ctrl+u arunksit Linux - Newbie 2 05-28-2008 07:15 PM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 11:26 AM
Can you reproduce this? LQtoto Linux - Security 1 05-08-2004 04:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration