/ctdb/events.d/41.httpd

http://github.com/brinkman83/bashrc · Shell · 68 lines · 47 code · 16 blank · 5 comment · 5 complexity · 873071d66dff7e5868899264bf2607c1 MD5 · raw file

  1. #!/bin/sh
  2. # event script to manage httpd in a cluster environment
  3. . $CTDB_BASE/functions
  4. detect_init_style
  5. case $CTDB_INIT_STYLE in
  6. redhat)
  7. service_name="httpd"
  8. service_config="http"
  9. ;;
  10. suse|debian|*)
  11. service_name="apache2"
  12. service_config="apache2"
  13. ;;
  14. esac
  15. # RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
  16. # semaphores. This is a hack to clean them up.
  17. cleanup_httpd_semaphore_leak() {
  18. killall -q -0 "$service_name" ||
  19. for i in $(ipcs -s | awk '$3 == "apache" { print $2 }') ; do
  20. ipcrm -s $i
  21. done
  22. }
  23. ##########
  24. service_start="cleanup_httpd_semaphore_leak; service $service_name start"
  25. service_stop="service $service_name stop; killall -q -9 $service_name || true"
  26. service_reconfigure="service $service_name restart"
  27. loadconfig
  28. ctdb_start_stop_service
  29. is_ctdb_managed_service || exit 0
  30. case "$1" in
  31. startup)
  32. ctdb_service_start
  33. ;;
  34. shutdown)
  35. ctdb_service_stop
  36. ;;
  37. monitor)
  38. if ctdb_service_needs_reconfigure ; then
  39. ctdb_service_reconfigure
  40. exit 0
  41. fi
  42. if ! ctdb_check_tcp_ports 80 ; then
  43. echo "HTTPD is not running. Trying to restart HTTPD."
  44. ctdb_service_start
  45. exit 1
  46. fi
  47. ;;
  48. *)
  49. ctdb_standard_event_handler "$@"
  50. ;;
  51. esac
  52. exit 0