ports/86402: [patch] Correction to prevent multiple stops's and starts's when calling restart on www/apache2 when using apache2_profiles
Jarrod Sayers
jarrod at netleader.com.au
Wed Sep 21 10:40:03 UTC 2005
>Number: 86402
>Category: ports
>Synopsis: [patch] Correction to prevent multiple stops's and starts's when calling restart on www/apache2 when using apache2_profiles
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Sep 21 10:40:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Jarrod Sayers
>Release: FreeBSD 4.11-RELEASE-p11 i386
>Organization:
>Environment:
System: FreeBSD manhattan.netleader.com.au 4.11-RELEASE-p11 FreeBSD 4.11-RELEASE-p11 #21: Sun Jul 3 15:43:12 CST 2005 root at manhattan.netleader.com.au:/usr/obj/usr/src/sys/MANHATTAN i386
Port: www/apache2
$FreeBSD: ports/www/apache2/Makefile,v 1.226 2005/09/07 20:31:11 clement Exp $
$FreeBSD: ports/www/apache2/files/apache.sh,v 1.14 2005/09/05 15:07:49 clement Exp $
>Description:
When www/apache2 is configured to use profiles, multiple start's and stop's are
called when the restart directive is issued. When a large number of profiles
are used, *every* profile is started and stoped for each profile, instead of
each profile individually, i.e., when 5 profiles are configured, each profile
restarts 5 times.
When issuing a reload (a simple signal sent by rc.subr), each profile reloads,
just once:
manhattan# /usr/local/etc/rc.d/apache2.sh reload
===> apache2 profile: httpd171
Reloading apache2 config files.
Performing sanity check on apache2 configuration:
Syntax OK
===> apache2 profile: httpd171old
Reloading apache2 config files.
Performing sanity check on apache2 configuration:
Syntax OK
===> apache2 profile: httpd172
Reloading apache2 config files.
Performing sanity check on apache2 configuration:
Syntax OK
manhattan#
Yet on a restart ($0 start, $0 stop sent by rc.subr), the apache.sh script calls
itself again for each profile (just ignore the fact that httpd171 was stopped
when I called it last):
manhattan# /usr/local/etc/rc.d/apache2.sh restart
===> apache2 profile: httpd171
Performing sanity check on apache2 configuration:
Syntax OK
===> apache2 profile: httpd171
apache2 not running? (check /var/run/httpd.httpd171.pid).
===> apache2 profile: httpd171old
Stopping apache2.
Waiting for PIDS: 78303.
===> apache2 profile: httpd172
Stopping apache2.
Waiting for PIDS: 78310.
===> apache2 profile: httpd171
Starting apache2.
===> apache2 profile: httpd171old
Starting apache2.
===> apache2 profile: httpd172
Starting apache2.
===> apache2 profile: httpd171old
Performing sanity check on apache2 configuration:
Syntax OK
===> apache2 profile: httpd171
Stopping apache2.
Waiting for PIDS: 78417.
===> apache2 profile: httpd171old
Stopping apache2.
Waiting for PIDS: 78429.
===> apache2 profile: httpd172
Stopping apache2.
Waiting for PIDS: 78436.
===> apache2 profile: httpd171
Starting apache2.
===> apache2 profile: httpd171old
Starting apache2.
===> apache2 profile: httpd172
Starting apache2.
===> apache2 profile: httpd172
Performing sanity check on apache2 configuration:
Syntax OK
===> apache2 profile: httpd171
Stopping apache2.
Waiting for PIDS: 78494.
===> apache2 profile: httpd171old
Stopping apache2.
Waiting for PIDS: 78506.
===> apache2 profile: httpd172
Stopping apache2.
Waiting for PIDS: 78518.
===> apache2 profile: httpd171
Starting apache2.
===> apache2 profile: httpd171old
Starting apache2.
===> apache2 profile: httpd172
Starting apache2.
manhattan# logout
Or the 'set -x' version:
# /usr/local/etc/rc.d/apache2.sh restart 2>&1 | grep apache2.sh
+ /usr/local/etc/rc.d/apache2.sh restart httpd171
You can see by the next line, that rc.subr has called 'stop' and is not
aware that there was a profile attached to the restart line above, so
apache.sh proceedes to stop everything.
+ /usr/local/etc/rc.d/apache2.sh stop
+ /usr/local/etc/rc.d/apache2.sh stop httpd171
+ /usr/local/etc/rc.d/apache2.sh stop httpd171old
+ /usr/local/etc/rc.d/apache2.sh stop httpd172
+ /usr/local/etc/rc.d/apache2.sh start
+ /usr/local/etc/rc.d/apache2.sh start httpd171
+ /usr/local/etc/rc.d/apache2.sh start httpd171old
+ /usr/local/etc/rc.d/apache2.sh start httpd172
So, apache.sh, thinking its just restarted the first profile, goes away
to restart the next one.
+ /usr/local/etc/rc.d/apache2.sh restart httpd171old
+ /usr/local/etc/rc.d/apache2.sh stop
+ /usr/local/etc/rc.d/apache2.sh stop httpd171
+ /usr/local/etc/rc.d/apache2.sh stop httpd171old
+ /usr/local/etc/rc.d/apache2.sh stop httpd172
+ /usr/local/etc/rc.d/apache2.sh start
+ /usr/local/etc/rc.d/apache2.sh start httpd171
+ /usr/local/etc/rc.d/apache2.sh start httpd171old
+ /usr/local/etc/rc.d/apache2.sh start httpd172
Whee....
+ /usr/local/etc/rc.d/apache2.sh restart httpd172
+ /usr/local/etc/rc.d/apache2.sh stop
+ /usr/local/etc/rc.d/apache2.sh stop httpd171
+ /usr/local/etc/rc.d/apache2.sh stop httpd171old
+ /usr/local/etc/rc.d/apache2.sh stop httpd172
+ /usr/local/etc/rc.d/apache2.sh start
+ /usr/local/etc/rc.d/apache2.sh start httpd171
+ /usr/local/etc/rc.d/apache2.sh start httpd171old
+ /usr/local/etc/rc.d/apache2.sh start httpd172
#
>How-To-Repeat:
Install www/apache2 from ports:
manhattan# cd /usr/ports/www/apache2
manhattan# make install clean
Add lines to /etc/rc.conf to enable apache2 profiles (filenames are fake):
apache2_enable="YES"
apache2_profiles="httpd1 httpd2 httpd3"
apache2_httpd1_configfile="/usr/local/etc/apache2/httpd1.conf"
apache2_httpd2_configfile="/usr/local/etc/apache2/httpd2.conf"
apache2_httpd3_configfile="/usr/local/etc/apache2/httpd3.conf"
Run:
manhattan# /usr/local/etc/rc.d/apache2.sh restart
>Fix:
Don't rerun the apache2.sh rc script on restart's, just stop and start normally:
--- www/apache2/files/apache.sh.orig Sat Sep 10 09:31:50 2005
+++ www/apache2/files/apache.sh Wed Sep 21 19:56:01 2005
@@ -67,7 +67,7 @@
echo "$0: extra argument ignored"
fi
else
- if [ "x${apache2_profiles}" != "x" ]; then
+ if [ "x${apache2_profiles}" != "x" -a "x${1}" != "xrestart" ]; then
for profile in ${apache2_profiles}; do
echo "===> apache2 profile: ${profile}"
$0 $1 $profile
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list