Created
October 9, 2015 14:03
-
-
Save reggieb/1d3c2685d786439366ec to your computer and use it in GitHub Desktop.
God script to keep apache alive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APACHE_ROOT = 'path/to/apache' | |
def apache(location) | |
File.join APACHE_ROOT, location | |
end | |
def apachectl(command) | |
"#{apache 'bin/apachectl'} -k #{command}" | |
end | |
God.watch do |watch| | |
watch.name = 'apache' | |
watch.interval = 30.seconds | |
watch.start = apachectl 'start' | |
watch.stop = apachectl 'stop' | |
watch.restart = apachectl 'graceful' | |
watch.start_grace = 10.seconds | |
watch.restart_grace = 10.seconds | |
watch.pid_file = apache 'logs/httpd.pid' # path to pid file may be '/var/run/httpd.pid' | |
watch.start_if do |start| | |
start.condition(:process_running) do |condition| | |
condition.interval = 5.seconds | |
condition.running = false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After: http://blog.blenderbox.com/2008/03/11/monitoring-apache-with-god/