From 86ad711c372b252ce1d23ecaf9a1514958bdb8df Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 11 May 2009 14:50:28 +1000 Subject: 41.httpd event script workaround for RHEL5-ism. RHEL5 can SIGKILL httpd when stopping it, causing it to leak semaphores. This means that eventually a node runs out of semaphores and httpd can't be started. So, before we attempt to start httpd we clean up any semaphores owned by apache. We also try to restart httpd in the monitor event if httpd has gone away. Signed-off-by: Martin Schwenke (This used to be ctdb commit 2d3fbbbb63f443686f9fec42c0bc2058d115806e) --- ctdb/config/events.d/41.httpd | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd index fae9f47f55..4d8c44008b 100755 --- a/ctdb/config/events.d/41.httpd +++ b/ctdb/config/events.d/41.httpd @@ -34,19 +34,35 @@ loadconfig "${CTDB_CONFIG_HTTP}" cmd="$1" shift -case $cmd in - startup) - service "${CTDB_SERVICE_HTTP}" stop > /dev/null 2>&1 - service "${CTDB_SERVICE_HTTP}" start - ;; +# 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 "${CTDB_SERVICE_HTTP}" || + for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do + ipcrm -s $i + done +} - shutdown) - service "${CTDB_SERVICE_HTTP}" stop - ;; +case $cmd in + startup) + cleanup_httpd_semaphore_leak + service "${CTDB_SERVICE_HTTP}" start + ;; + + shutdown) + service "${CTDB_SERVICE_HTTP}" stop + killall -q -9 "${CTDB_SERVICE_HTTP}" + ;; monitor) - ctdb_check_tcp_ports "http" 80 - ;; + ( ctdb_check_tcp_ports "http" 80 ) + if [ $? -ne 0 ] ; then + echo "HTTPD is not running. Trying to restart HTTPD." + cleanup_httpd_semaphore_leak + service "${CTDB_SERVICE_HTTP}" start + exit 1 + fi + ;; esac exit 0 -- cgit