Bug 86402 - [patch] Correction to prevent multiple stops's and starts's when calling restart on www/apache2 when using apache2_profiles
Summary: [patch] Correction to prevent multiple stops's and starts's when calling rest...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Clement Laforet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-21 11:40 UTC by Jarrod Sayers
Modified: 2005-10-30 20:52 UTC (History)
0 users

See Also:


Attachments
file.diff (401 bytes, patch)
2005-09-21 11:40 UTC, Jarrod Sayers
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jarrod Sayers 2005-09-21 11:40:01 UTC
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
#

Fix: Don't rerun the apache2.sh rc script on restart's, just stop and start normally:
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
Comment 1 Marcus Alves Grando freebsd_committer 2005-09-21 13:21:56 UTC
Responsible Changed
From-To: freebsd-ports-bugs->clement

Over to maintainer
Comment 2 Clement Laforet freebsd_committer 2005-10-30 20:52:06 UTC
State Changed
From-To: open->closed

Committed, thanks!