Skip to content

Instantly share code, notes, and snippets.

@reggieb
Created October 9, 2015 14:03
Show Gist options
  • Save reggieb/1d3c2685d786439366ec to your computer and use it in GitHub Desktop.
Save reggieb/1d3c2685d786439366ec to your computer and use it in GitHub Desktop.
God script to keep apache alive
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
@reggieb
Copy link
Author

reggieb commented Oct 9, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment