1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/ctdb/config/events.d/41.httpd
Martin Schwenke e70e77383c ctdb-scripts: Drop configuration variable CTDB_SERVICE_AUTOSTARTSTOP
This has bit-rotted, at least for NFS.  It can be fixed but it is
better to remove it because it adds a lot of unnecessary complexity.

Variable event_name becomes unused so remove it.  Also remove
associated tests.

To continue to manage/unmanage services while CTDB is running:

* Start service by hand and then flag it as managed

* Mark service as unmanaged and shut it down by hand

In some cases CTDB does something fancy - e.g. start Samba under
"nice", so care is needed.  One technique is to disable the
eventscript, mark as managed, run the startup event by hand and then
re-enable the eventscript.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-01-16 11:57:07 +01:00

84 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# event script to manage httpd in a cluster environment
[ -n "$CTDB_BASE" ] || \
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
detect_init_style
case $CTDB_INIT_STYLE in
redhat)
service_name="httpd"
# service_config is used by loadconfig()
# shellcheck disable=SC2034
service_config="http"
;;
suse|debian|*)
service_name="apache2"
# service_config is used by loadconfig()
# shellcheck disable=SC2034
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
}
loadconfig
is_ctdb_managed_service || exit 0
case "$1" in
startup)
ctdb_service_start
;;
shutdown)
ctdb_service_stop
;;
monitor)
if ctdb_check_tcp_ports 80 >/dev/null 2>/dev/null ; then
ctdb_counter_init
else
ctdb_counter_incr
num_fails=$(ctdb_counter_get)
if [ "$num_fails" -eq 2 ] ; then
echo "HTTPD is not running. Trying to restart HTTPD."
service_stop
service_start
exit 0
elif [ "$num_fails" -ge 5 ] ; then
echo "HTTPD is not running. Trying to restart HTTPD."
service_stop
service_start
exit 1
fi
fi
;;
esac
exit 0