PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/ctdb/events.d/41.httpd

http://github.com/brinkman83/bashrc
Shell | 68 lines | 47 code | 16 blank | 5 comment | 5 complexity | 873071d66dff7e5868899264bf2607c1 MD5 | raw file
 1#!/bin/sh
 2# event script to manage httpd in a cluster environment
 3
 4. $CTDB_BASE/functions
 5
 6detect_init_style
 7
 8case $CTDB_INIT_STYLE in
 9    redhat)
10	service_name="httpd"
11	service_config="http"
12	;;
13    suse|debian|*)
14	service_name="apache2"
15	service_config="apache2"
16	;;
17esac
18
19# RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
20# semaphores.  This is a hack to clean them up.
21cleanup_httpd_semaphore_leak() {
22    killall -q -0 "$service_name" ||
23    for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do
24	ipcrm -s $i
25    done
26}
27
28##########
29
30service_start="cleanup_httpd_semaphore_leak; service $service_name start"
31service_stop="service $service_name stop; killall -q -9 $service_name || true"
32service_reconfigure="service $service_name restart"
33
34loadconfig
35
36ctdb_start_stop_service
37
38is_ctdb_managed_service || exit 0
39
40case "$1" in
41    startup)
42	ctdb_service_start
43	;;
44
45    shutdown)
46	ctdb_service_stop
47	;;
48
49    monitor)
50	if ctdb_service_needs_reconfigure ; then
51	    ctdb_service_reconfigure
52	    exit 0
53	fi
54
55	if ! ctdb_check_tcp_ports 80 ; then
56	    echo "HTTPD is not running. Trying to restart HTTPD."
57	    ctdb_service_start
58	    exit 1
59	fi
60	;;
61
62    *)
63	ctdb_standard_event_handler "$@"
64	;;
65esac
66
67exit 0
68