diff options
author | Martin Schwenke <martin@meltin.net> | 2009-05-11 14:50:28 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-05-12 08:53:32 +1000 |
commit | 86ad711c372b252ce1d23ecaf9a1514958bdb8df (patch) | |
tree | 87ef7d4ef7188776b226d86bf70b15e3c8a866c4 | |
parent | 54a5e6c0c88ca6369474d85ef41c5ad1f1f455ae (diff) | |
download | samba-86ad711c372b252ce1d23ecaf9a1514958bdb8df.tar.gz samba-86ad711c372b252ce1d23ecaf9a1514958bdb8df.tar.xz samba-86ad711c372b252ce1d23ecaf9a1514958bdb8df.zip |
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 <martin@meltin.net>
(This used to be ctdb commit 2d3fbbbb63f443686f9fec42c0bc2058d115806e)
-rwxr-xr-x | ctdb/config/events.d/41.httpd | 36 |
1 files 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 |