mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
428e32d647
service_start is currently a variable. This makes passing arguments hard. We change it to be a function and put default definitions into the functions file. We use a convention that if a service name argument is passed to a redefined version of service_start() or service_stop() then it will act unconditionally. If no argument is passed then it can use internal logic to decide if services should really be started. This is useful when a single eventscript handles multiple services. This is a cherry-pick of ae38895 that needed to be reset mid-stream. There is still some breakage following this commit. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 86e4aefed9fd1028660c98e3ea758c2b75ffc1d8)
90 lines
1.5 KiB
Bash
Executable File
90 lines
1.5 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 >/dev/null 2>/dev/null ; then
|
|
ctdb_counter_init
|
|
else
|
|
ctdb_counter_incr
|
|
|
|
ctdb_check_counter_equal 5 || {
|
|
echo "HTTPD is not running. Trying to restart HTTPD."
|
|
ctdb_service_stop
|
|
ctdb_service_start
|
|
exit 0
|
|
}
|
|
ctdb_check_counter_limit 10 quiet|| {
|
|
echo "HTTPD is not running. Trying to restart HTTPD."
|
|
ctdb_service_stop
|
|
ctdb_service_start
|
|
exit 1
|
|
}
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
ctdb_standard_event_handler "$@"
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
|