7 if [ "$CONFIG_APACHE_MODE" == none
]; then
11 # Start httpd in the C locale by default.
14 # This will prevent initlog from swallowing up a pass-phrase prompt if
15 # mod_ssl needs a pass-phrase from the user.
18 APACHE_RUN_USER
="###SITE###"
19 APACHE_RUN_GROUP
="###SITE###"
21 APACHE_BIN
="###APACHE_BIN###"
22 PID_FILE
=###ROOT###/tmp/apache/run/apache.pid
23 CONFIG_FILE
=###ROOT###/etc/apache/apache.conf
26 # if there is actually an apache2 process whose pid is in PIDFILE,
27 # print it and return 0.
28 if [ -e "$PID_FILE" ]; then
29 PID
=$
(cat "$PID_FILE")
30 if kill -0 $PID >/dev
/null
2>&1; then
35 # It might happen that there is no pidfile but a process is running
36 # As fallback check the process table for the oldest apache process
37 # running as this user
38 PID
=$
(pgrep
-u $OMD_SITE -o -f $APACHE_BIN)
39 if [ -n "$PID" ]; then
49 pid
=$
(pidof_apache
) || true
50 if [ -n "${pid:-}" ]; then
53 echo -n '(not running)...'
57 # wait until really stopped
58 if [ -n "${pid:-}" ]; then
60 while kill -0 "${pid:-}" 2> /dev
/null
; do
61 if [ $i = '120' ]; then
72 [ -f "$PID_FILE" ] && rm -f "$PID_FILE"
78 if pidof_apache
>/dev
/null
2>&1; then
79 echo -n '(already running)...'
83 mkdir
-p ###ROOT###/tmp/apache/run
85 # (nearly) reproducible problems with apache at boot-time. (alloc_listener: failed to set up sockaddr for 127.0.0.1)
86 # With this ping the problem disappears.
87 test -f /etc
/debian_version
&& test $
(cut
-f1 -d" " /proc
/uptime | cut
-f1 -d".") -lt 300 && ping -nqc 10 $CONFIG_APACHE_TCP_ADDR >/dev
/null
2>&1
88 $APACHE_BIN -f "$CONFIG_FILE"
91 while ! pidof_apache
>/dev
/null
2>&1; do
92 if [ $i = '10' ]; then
104 kill_stale_php_cgis
()
107 killall
-e ###PHP_FCGI_BIN### -u ###SITE### >/dev/null 2>&1
108 while killall
-e ###PHP_FCGI_BIN### -u ###SITE### >/dev/null 2>&1
111 if [ $i -gt 50 ] ; then
118 __init_hook
$0 $1 pre
121 echo -n "Starting dedicated Apache for site ###SITE###..."
122 if apache_wait_start
; then
123 __init_hook
$0 $1 post
0
127 __init_hook
$0 $1 post
1
133 echo -n "Stopping dedicated Apache for site ###SITE###..."
134 if apache_wait_stop
; then
135 __init_hook
$0 $1 post
0
139 __init_hook
$0 $1 post
1
149 echo "Reloading dedicated Apache for site ###SITE###"
150 $APACHE_BIN -f "$CONFIG_FILE" -k graceful
151 __init_hook
$0 $1 post $?
154 PID
=$
(pidof_apache
) || true
155 if [ -n "$PID" ]; then
156 echo "Apache is running (pid $PID)."
159 echo "Apache is NOT running."
164 echo "Usage: $0 {start|stop|restart|reload|status}"