From 8b23253afb124d8ac74414002d545ad4f1f9a86c Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Fri, 11 Sep 2009 18:34:41 +0000 Subject: [PATCH] Backport of r813972: Fix the RPM init.d script to correctly take into account the pid file when starting and stopping the server. This prevents the init script from blowing away other instances of httpd that might be running on the same machine when someone attempts to stop the server. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@813973 13f79535-47bb-0310-9956-ffa450edef68 --- build/rpm/httpd.init | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/build/rpm/httpd.init b/build/rpm/httpd.init index be9c2e16bc5..53521270274 100755 --- a/build/rpm/httpd.init +++ b/build/rpm/httpd.init @@ -16,14 +16,24 @@ # limitations under the License. # # -# Startup script for the Apache Web Server +# httpd Startup script for the Apache Web Server # # chkconfig: - 85 15 -# description: Apache is a World Wide Web server. It is used to serve \ -# HTML files and CGI. +# description: The Apache HTTP Server is an efficient and extensible \ +# server implementing the current HTTP standards. # processname: httpd -# pidfile: /var/run/httpd.pid -# config: /etc/httpd/conf/httpd.conf +# pidfile: /var/log/httpd/httpd.pid +# config: /etc/sysconfig/httpd +# +### BEGIN INIT INFO +# Provides: httpd +# Required-Start: $local_fs $remote_fs $network $named +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: distcache +# Short-Description: start and stop Apache HTTP Server +# Description: The Apache HTTP Server is an extensible server +# implementing the current HTTP standards. +### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions @@ -44,6 +54,8 @@ INITLOG_ARGS="" apachectl=/usr/sbin/apachectl httpd=${HTTPD-/usr/sbin/httpd} prog=httpd +pidfile=${PIDFILE-/var/log/httpd/httpd.pid} +lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 # check for 1.3 configuration @@ -69,23 +81,23 @@ check13 () { start() { echo -n $"Starting $prog: " check13 || exit 1 - daemon $httpd $OPTIONS + daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo - [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd + [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping $prog: " - killproc $httpd + killproc -p ${pidfile} $httpd RETVAL=$? echo - [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid + [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " check13 || exit 1 - killproc $httpd -HUP + killproc -p ${pidfile} $httpd -HUP RETVAL=$? echo } @@ -99,7 +111,7 @@ case "$1" in stop ;; status) - status $httpd + status -p ${pidfile} $httpd RETVAL=$? ;; restart) @@ -107,7 +119,7 @@ case "$1" in start ;; condrestart) - if [ -f /var/run/httpd.pid ] ; then + if status -p ${pidfile} $httpd >&/dev/null; then stop start fi -- 2.47.3