1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00
samba-mirror/ctdb/config/events.d/41.httpd
Martin Schwenke db25ca69e5 Eventscript argument cleanups and introduction of ctdb_standard_event_handler.
The functions file no longer causes a side-effect by doing a shift.
It also doesn't set a convenience variable for $1.

All eventscripts now explicitly use "$1" in their case statement, as
does the initscript.  The absence of a shift means that the
takeip/releaseip events now explicitly reference $2-$4 rather than
$1-$3.

New function ctdb_standard_event_handler handles the status and
setstatus events, and exits for either of those events.  It is called
via a default case in each eventscript, replacing an explicit status
case where applicable.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 3d55408cbbb3bb71670b80f3dad5639ea0be5b5b)
2009-12-01 17:43:47 +11:00

69 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# event script to manage httpd in a cluster environment
. $CTDB_BASE/functions
detect_init_style
case $CTDB_INIT_STYLE in
redhat)
service_name="httpd"
service_config="http"
;;
suse|debian|*)
service_name="apache2"
service_config="apache2"
;;
esac
# RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
# semaphores. This is a hack to clean them up.
cleanup_httpd_semaphore_leak() {
killall -q -0 "$service_name" ||
for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do
ipcrm -s $i
done
}
##########
service_start="cleanup_httpd_semaphore_leak; service $service_name start"
service_stop="service $service_name stop; killall -q -9 $service_name || true"
service_reconfigure="service $service_name restart"
loadconfig
ctdb_start_stop_service
is_ctdb_managed_service || exit 0
case "$1" in
startup)
ctdb_service_start
;;
shutdown)
ctdb_service_stop
;;
monitor)
if ctdb_service_needs_reconfigure ; then
ctdb_service_reconfigure
exit 0
fi
if ! ctdb_check_tcp_ports 80 ; then
echo "HTTPD is not running. Trying to restart HTTPD."
ctdb_service_start
exit 1
fi
;;
*)
ctdb_standard_event_handler "$@"
;;
esac
exit 0