You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Todd Weaver <to...@m2n.com> on 2006/01/27 20:54:35 UTC
apachectl hardstart?
I've had need in the past to stop, sleep, start apache.
The reason for such action(s) has been writing external modules and
loading SSL certificates.
Recently I wrote an SSL self signing generation script, that after
generation required an 'apachectl stop && sleep 5 && apachectl start'
or the like.
Instead of sleeping for an arbitrary time without guarantee of shutdown
before a start request, I added the below 'hardstart'.
hardstart sleeps at most 1 second past the shutdown completing, then starts.
I'm not sure if others would find it beneficial, so before filing a patch,
I figured I'd see if 'hardstart' would be of any use to others.
Or if anybody had any improvements to the code.
(example: throw a different error code for hardstart failure?)
Feedback?
Todd.
###
cvs diff -u apachectl
Index: apachectl
===================================================================
RCS file: /home/cvspublic/apache-1.3/src/support/apachectl,v
retrieving revision 1.22
diff -u -r1.22 apachectl
--- apachectl 20 Feb 2004 22:02:24 -0000 1.22
+++ apachectl 27 Jan 2006 19:42:18 -0000
@@ -163,6 +163,34 @@
ERROR=8
fi
;;
+ hardstart)
+ if [ $RUNNING -eq 0 ]; then
+ echo "$0 $ARG: httpd not running, trying to start"
+ if $HTTPD ; then
+ echo "$0 $ARG: httpd started"
+ else
+ echo "$0 $ARG: httpd could not be started"
+ ERROR=5
+ fi
+ else
+ if kill $PID ; then
+ echo "$0 $ARG: httpd stopped"
+ else
+ echo "$0 $ARG: httpd could not be stopped"
+ ERROR=4
+ fi
+ while [ -f $PIDFILE ]; do
+ sleep 1
+ echo "$0 $ARG: waiting to close $PIDFILE"
+ done
+ if $HTTPD ; then
+ echo "$0 $ARG: httpd started"
+ else
+ echo "$0 $ARG: httpd could not be started"
+ ERROR=3
+ fi
+ fi
+ ;;
*)
echo "usage: $0 (start|stop|restart|fullstatus|status|graceful|configtest|help)"
cat <<EOF
@@ -175,6 +203,8 @@
status - dump a short status screen; requires lynx and mod_status enabled
graceful - do a graceful restart by sending a SIGUSR1 or start if not running
configtest - do a configuration syntax test
+hardstart - stop httpd, wait for shutdown, then start httpd or start if
+ not running
help - this screen
EOF