2 # event script to manage httpd in a cluster environment
4 [ -n "$CTDB_BASE" ] || \
5 CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
7 . "${CTDB_BASE}/functions"
11 case $CTDB_INIT_STYLE in
16 service_name="apache2"
22 ctdb_setup_state_dir "service" "$service_name"
24 # RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
25 # semaphores. This is a hack to clean them up.
26 cleanup_httpd_semaphore_leak() {
27 killall -q -0 "$service_name" ||
28 for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do
37 cleanup_httpd_semaphore_leak
38 service $service_name start
42 service $service_name stop
43 killall -q -9 $service_name || true
46 [ "$CTDB_MANAGES_HTTPD" = "yes" ] || exit 0
59 if ctdb_check_tcp_ports 80 >/dev/null 2>/dev/null ; then
63 num_fails=$(ctdb_counter_get)
64 if [ "$num_fails" -eq 2 ] ; then
65 echo "HTTPD is not running. Trying to restart HTTPD."
69 elif [ "$num_fails" -ge 5 ] ; then
70 echo "HTTPD is not running. Trying to restart HTTPD."