View | Details | Raw Unified | Return to bug 54622
Collapse All | Expand All

(-)support/apachectl.orig (-2 / +78 lines)
Lines 54-60 Link Here
54
HTTPD_NICE=0 # was set to 3, but is redundand if IO scheduler is not cfq
54
HTTPD_NICE=0 # was set to 3, but is redundand if IO scheduler is not cfq
55
ulimit -v $HTTPD_MEM
55
ulimit -v $HTTPD_MEM
56
HTTPD="/bin/nice -$HTTPD_NICE $HTTPD"
56
HTTPD="/bin/nice -$HTTPD_NICE $HTTPD"
57
#
57
58
HTTPD_LOG_DIR="/apache/logs"
59
HTTPD_PID_FILE="$HTTPD_LOG_DIR/httpd.pid"
60
HTTPD_MOD_AUTH_DIGEST_PID_BASE="$HTTPD_LOG_DIR/authdigest_shm"
61
58
# a command that outputs a formatted text version of the HTML at the
62
# a command that outputs a formatted text version of the HTML at the
59
# url given on the command line.  Designed for lynx, however other
63
# url given on the command line.  Designed for lynx, however other
60
# programs may work.  
64
# programs may work.  
Lines 72-77 Link Here
72
# --------------------                              --------------------
76
# --------------------                              --------------------
73
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
77
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
74
78
79
80
# Remove Shared Memory Segments by id
81
cleanup_shm_id() {
82
    ipcs -m -p |grep ^[0-9] |while read shmid owner cpid lpid; do
83
        [ "$cpid" = "$1" ] || continue
84
        echo "Removing stale shmid $shmid for cpid $cpid ..."
85
        ipcrm -m $shmid
86
    done
87
}
88
89
# Remove all Semaphore Arrays owned by apache
90
cleanup_sem_ids() {
91
    ipcs -s |grep "[[:space:]]apache[[:space:]]" |while read key semid owner perms nsems; do
92
        echo "Removing stale semid $semid for owner $owner ..."
93
        ipcrm -s $semid
94
    done
95
}
96
97
cleanup_stale_state_on_startup() {
98
    local HTTPD_PID
99
    local STALE_PIDS
100
    local MAD_PID_PATH
101
    local PID
102
103
    # httpd.pid
104
    if [ -f $HTTPD_PID_FILE ]; then
105
        HTTPD_PID=$(cat $HTTPD_PID_FILE)
106
        [ "$(ps -p "$HTTPD_PID" --no-headers -o ucmd)" = "httpd" ] && return
107
108
        STALE_PIDS="$HTTPD_PID"
109
        echo "Stale pid $HTTPD_PID - unclean shutdown of previous Apache run?"
110
        rm -v $HTTPD_PID_FILE
111
        cleanup_sem_ids
112
    fi
113
114
    # authdigest_shm.*
115
    for MAD_PID_PATH in $(echo ${HTTPD_MOD_AUTH_DIGEST_PID_BASE}.*); do
116
        [ "$MAD_PID_PATH" = "${HTTPD_MOD_AUTH_DIGEST_PID_BASE}.*" ] && return # not found
117
118
        echo "Stale $MAD_PID_PATH - unclean shutdown of previous Apache run?"
119
120
        STALE_PIDS="$STALE_PIDS ${MAD_PID_PATH##*.}"
121
        rm -v "$MAD_PID_PATH"
122
    done
123
124
    for PID in $STALE_PIDS; do
125
        cleanup_shm_id $PID
126
    done
127
}
128
75
# Set the maximum number of file descriptors allowed per child process.
129
# Set the maximum number of file descriptors allowed per child process.
76
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
130
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
77
    $ULIMIT_MAX_FILES
131
    $ULIMIT_MAX_FILES
Lines 83-89 Link Here
83
fi
137
fi
84
138
85
case $ACMD in
139
case $ACMD in
86
start|stop|restart|graceful|graceful-stop)
140
stop)
141
    if [ ! -f "$HTTPD_PID_FILE" ]; then
142
        echo "no httpd pid file"
143
        exit 4
144
    fi
145
146
    HTTPD_PID=$(cat "$HTTPD_PID_FILE")
147
    PS_CMD=$(ps -p "$HTTPD_PID" --no-headers -o ucmd)
148
149
    if [ "$PS_CMD" = "" ]; then
150
        echo "httpd (pid $HTTPD_PID?) not running"
151
        exit 4
152
    fi
153
154
    if [ "$PS_CMD" != "httpd" ]; then
155
        echo "process name [$PS_CMD] for pid [$HTTPD_PID] ($HTTPD_PID_FILE) is not httpd"
156
        exit 4
157
    fi
158
159
    kill -TERM $HTTPD_PID || exit 4
160
    ;;
161
start|restart|graceful|graceful-stop)
162
    cleanup_stale_state_on_startup
87
    $HTTPD -k $ARGV
163
    $HTTPD -k $ARGV
88
    ERROR=$?
164
    ERROR=$?
89
    ;;
165
    ;;

Return to bug 54622