1 |
commit: d8a7383814bbdb63d658200b473bac586b6255b6 |
2 |
Author: Peter Volkov <pva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Oct 18 06:10:33 2011 +0000 |
4 |
Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Oct 18 06:10:33 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/apache.git;a=commit;h=d8a73838 |
7 |
|
8 |
Use extra_{,started}commands, bug #385637 by Martin von Gagern. Check config during restart, bug #384997 wrt Christian Ruppert (idl0r). Don't use pidof to check for running instances to make it more ConTainer friendly, bug #384267 by Stef Simoens. Drop ssl_scache check as the problem it workarounds was fixed upstream years ago: https://issues.apache.org/bugzilla/show_bug.cgi?id=21335 . Dropped '# zap!' in gracefulstop. |
9 |
|
10 |
--- |
11 |
2.2/init/apache2.initd | 62 ++++++++++++++++++++++++++------------------------ |
12 |
1 file changed, 32 insertions(+), 30 deletions(-) |
13 |
|
14 |
diff --git a/2.2/init/apache2.initd b/2.2/init/apache2.initd |
15 |
index 66f1c73..249d3de 100755 |
16 |
--- a/2.2/init/apache2.initd |
17 |
+++ b/2.2/init/apache2.initd |
18 |
@@ -1,11 +1,12 @@ |
19 |
#!/sbin/runscript |
20 |
-# Copyright 1999-2007 Gentoo Foundation |
21 |
+# Copyright 1999-2011 Gentoo Foundation |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
|
24 |
-opts="configdump configtest fullstatus graceful gracefulstop modules reload virtualhosts" |
25 |
+extra_commands="configtest modules virtualhosts" |
26 |
+extra_started_commands="configdump fullstatus graceful gracefulstop reload" |
27 |
|
28 |
-description_configdump="Dumps the configuration of the apache server. Requires lynx and server-info to be enabled." |
29 |
-description_configtest="Run syntax tests for configuration files only." |
30 |
+description_configdump="Dumps the configuration of the runing apache server. Requires server-info to be enabled and www-client/lynx." |
31 |
+description_configtest="Run syntax tests for configuration files." |
32 |
description_fullstatus="Gives the full status of the server. Requires lynx and server-status to be enabled." |
33 |
description_graceful="A graceful restart advises the children to exit after the current request and reloads the configuration." |
34 |
description_gracefulstop="A graceful stop advises the children to exit after the current request and stops the server." |
35 |
@@ -27,8 +28,14 @@ configtest() { |
36 |
} |
37 |
|
38 |
checkconfd() { |
39 |
+ if [ ! -f /etc/init.d/sysfs ]; then |
40 |
+ eerror "This init script works only with openrc (baselayout-2)." |
41 |
+ eerror "If you still need baselayout-1.x, please, use" |
42 |
+ eerror "apache2.initd-baselayout-1 from /usr/share/doc/apache2-*/" |
43 |
+ fi |
44 |
+ |
45 |
PIDFILE="${PIDFILE:-/var/run/apache2.pid}" |
46 |
- TIMEOUT=${TIMEOUT:-10} |
47 |
+ TIMEOUT=${TIMEOUT:-15} |
48 |
|
49 |
SERVERROOT="${SERVERROOT:-/usr/lib/apache2}" |
50 |
if [ ! -d ${SERVERROOT} ]; then |
51 |
@@ -66,9 +73,8 @@ checkconfig() { |
52 |
start() { |
53 |
checkconfig || return 1 |
54 |
|
55 |
- [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache |
56 |
- |
57 |
ebegin "Starting ${SVCNAME}" |
58 |
+ # Use start stop daemon to apply system limits #347301 |
59 |
start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start |
60 |
|
61 |
i=0 |
62 |
@@ -76,30 +82,38 @@ start() { |
63 |
sleep 1 && i=$(expr $i + 1) |
64 |
done |
65 |
|
66 |
- test -e "${PIDFILE}" |
67 |
- eend $? |
68 |
+ eend $(test $i -lt ${TIMEOUT}) |
69 |
} |
70 |
|
71 |
stop() { |
72 |
- checkconfd || return 1 |
73 |
+ if [ "${RC_CMD}" = "restart" ]; then |
74 |
+ checkconfig || return 1 |
75 |
+ else |
76 |
+ checkconfd || return 1 |
77 |
+ fi |
78 |
+ |
79 |
+ PID=$(cat "${PIDFILE}" 2>/dev/null) |
80 |
+ if [ -z "${PID}" ]; then |
81 |
+ einfo "${SVCNAME} not running (no pid file)" |
82 |
+ return 0 |
83 |
+ fi |
84 |
|
85 |
ebegin "Stopping ${SVCNAME}" |
86 |
- start-stop-daemon --stop --pidfile ${PIDFILE} -- ${APACHE2} ${APACHE2_OPTS} -k stop |
87 |
+ ${APACHE2} ${APACHE2_OPTS} -k stop |
88 |
|
89 |
i=0 |
90 |
- while pidof "${APACHE2}" >/dev/null && [ $i -lt ${TIMEOUT} ]; do |
91 |
+ while ( ! test -f "${PIDFILE}" && pgrep -P ${PID} apache2 >/dev/null ) \ |
92 |
+ && [ $i -lt ${TIMEOUT} ]; do |
93 |
sleep 1 && i=$(expr $i + 1) |
94 |
done |
95 |
|
96 |
- test $i -lt ${TIMEOUT} |
97 |
- eend $? |
98 |
+ eend $(test $i -lt ${TIMEOUT}) |
99 |
} |
100 |
|
101 |
reload() { |
102 |
RELOAD_TYPE="${RELOAD_TYPE:-graceful}" |
103 |
|
104 |
checkconfig || return 1 |
105 |
- service_started "${SVCNAME}" || return |
106 |
|
107 |
if [ "${RELOAD_TYPE}" = "restart" ]; then |
108 |
ebegin "Restarting ${SVCNAME}" |
109 |
@@ -116,7 +130,6 @@ reload() { |
110 |
|
111 |
graceful() { |
112 |
checkconfig || return 1 |
113 |
- service_started "${SVCNAME}" || return |
114 |
ebegin "Gracefully restarting ${SVCNAME}" |
115 |
${APACHE2} ${APACHE2_OPTS} -k graceful |
116 |
eend $? |
117 |
@@ -124,12 +137,6 @@ graceful() { |
118 |
|
119 |
gracefulstop() { |
120 |
checkconfig || return 1 |
121 |
- |
122 |
- # zap! |
123 |
- if service_started "${SVCNAME}"; then |
124 |
- mark_service_stopped "${SVCNAME}" |
125 |
- fi |
126 |
- |
127 |
ebegin "Gracefully stopping ${SVCNAME}" |
128 |
${APACHE2} ${APACHE2_OPTS} -k graceful-stop |
129 |
eend $? |
130 |
@@ -137,7 +144,6 @@ gracefulstop() { |
131 |
|
132 |
modules() { |
133 |
checkconfig || return 1 |
134 |
- |
135 |
${APACHE2} ${APACHE2_OPTS} -M 2>&1 |
136 |
} |
137 |
|
138 |
@@ -145,9 +151,7 @@ fullstatus() { |
139 |
LYNX="${LYNX:-lynx -dump}" |
140 |
STATUSURL="${STATUSURL:-http://localhost/server-status}" |
141 |
|
142 |
- if ! service_started "${SVCNAME}"; then |
143 |
- eerror "${SVCNAME} not started" |
144 |
- elif ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then |
145 |
+ if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then |
146 |
eerror "lynx not found! you need to emerge www-client/lynx" |
147 |
else |
148 |
${LYNX} ${STATUSURL} |
149 |
@@ -155,7 +159,7 @@ fullstatus() { |
150 |
} |
151 |
|
152 |
virtualhosts() { |
153 |
- checkconfd || return 1 |
154 |
+ checkconfig || return 1 |
155 |
${APACHE2} ${APACHE2_OPTS} -S |
156 |
} |
157 |
|
158 |
@@ -165,9 +169,7 @@ configdump() { |
159 |
|
160 |
checkconfd || return 1 |
161 |
|
162 |
- if ! service_started "${SVCNAME}"; then |
163 |
- eerror "${SVCNAME} not started" |
164 |
- elif ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then |
165 |
+ if ! type -p $(set -- ${LYNX}; echo $1) 2>&1 >/dev/null; then |
166 |
eerror "lynx not found! you need to emerge www-client/lynx" |
167 |
else |
168 |
echo "${APACHE2} started with '${APACHE2_OPTS}'" |