Not acked.  Miss Files strikes again..
-- 
#ken    P-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist      http://Apache-Server.Com/

"All right everyone!  Step away from the glowing hamburger!"


Hello, Apache Team,

 The control script "apachectl" by Marc Slemko inspired me for a
similar script for the squid proxy server.
 After I posted the script on the squid mailing list, Colin Campbell
pointed to me that the script made a few assumptions that could lead to
a wrong conclusion.

apachectl from Slackware Linux 7.0 (Server version: Apache/1.3.9
(Unix))
=== Lines 50 through 63 ==========================
    # check for pidfile
    if [ -f $PIDFILE ] ; then
        PID=`cat $PIDFILE`
        if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
            STATUS="httpd (pid $PID) running"
            RUNNING=1
        else
            STATUS="httpd (pid $PID?) not running"
            RUNNING=0
        fi
    else
        STATUS="httpd (no pid file) not running"
        RUNNING=0
    fi
=======================================================================

 As pointed out by Colin Campbell, this code assumes that if a PID file
exists, it contains a PID number and a process is running with that
PID, then apache (in my case squid) is running. This assumption may be
false. 

Replace lines 50 through 63 with the following :
=======================================================================
    # check for pid file
    if [ -f $PIDFILE ]; then # PID file exists
        PID=`cat $PIDFILE`
        if [ "x$PID" != "x" ]; then # PID exists
            if kill -0 $PID 2>/dev/null ; then # a process using PID is
running
                if ps -p $PID -o args | grep httpd > /dev/null 2>&1;
then
                # that process is httpd itself, OK
                    STATUS="httpd (pid $PID) running"
                    RUNNING=1
                else
                # httpd not running, stale PID file contains PID of
another
                # running process. No httpd, remove the PID file
                    rm -f $PIDFILE
                    STATUS="httpd (stale pid file removed) not running"
                    RUNNING=0
                fi
            else
            # nothing using this PID. Remove file
                rm -f $PIDFILE
                STATUS="httpd (stale pid file removed) not running"
                RUNNING=0
            fi
        else
        # PID file is empty. httpd not running, remove file.
            rm -f $PIDFILE
            STATUS="httpd (stale pid file removed) not running"
            RUNNING=0
        fi
    else
    # No PID file, not running.
        STATUS="httpd (no pid) not running"
        RUNNING=0
    fi
=======================================================================

 My derivative for squid, called squidctl will be found on the squid
mailing list and on my personal homepage. 
 With permission from you, I would like to include this fix for
apachectl, also.

Attached is a diff file for patching apachectl directly.
Apply with patch -p0 < apachectl.diff.

--
Andrei Boros
Homepage : http://members.tripod.com/andrei_b



=====
ing. Andrei Boros
Centrul pt. Tehnologia Informatiei
Societatea Romana de Radiodifuziune

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

apachectl.tar.gz



Reply via email to