Rather than break and fail after 10s, would it be an idea to do a force kill, something like:
killall -9 httpd rm -f /var/run/httpd.pid
This is just a passing thought.
On 24/04/2024 16:56, Adolf Belka wrote:
- The change of the apache initscript in CU181 made the restart comand a stop followed by a start. From bug13656 it looks like when the start is run the pid file may not yet be fully removed and so apache is not started, although the pid is being removed.
- This patch checks if the pid file is still present every second up to 10 seconds. Once the pid file is gone then the stop command is completed and the initscript moves to the start command.
- Rather than apply a fixed delay of 2 or 3 or 4 seconds I used a while loop to check every second if the file is still present. If at the end of 10 seconds it is still present then something went wrong with the pid removal.
- I have tested this patch on my vm system and it worked but it would be good to be reviewed to make sure that it is a reasonable approach that has been used and if required changed in whatever way makes the best sense.
Fixes: Bug13656 Tested-by: Adolf Belkaadolf.belka@ipfire.org Signed-off-by: Adolf Belkaadolf.belka@ipfire.org
src/initscripts/system/apache | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/initscripts/system/apache b/src/initscripts/system/apache index 18eb86e2f..087e4084e 100644 --- a/src/initscripts/system/apache +++ b/src/initscripts/system/apache @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2022 IPFire Teaminfo@ipfire.org # +# Copyright (C) 2007-2024 IPFire Teaminfo@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -87,6 +87,16 @@ case "$1" in stop) boot_mesg "Stopping Apache daemon..." /usr/sbin/apachectl -k stop
COUNTER=0
while [ -e /var/run/httpd.pid ]
do
sleep 1
(( COUNTER++ ))
if [ $COUNTER -eq 10 ]; then
boot_mesg "pid not removed after 10 seconds"
break
fi
evaluate_retval ;;done