Created
December 28, 2011 23:25
-
-
Save Gurpartap/1530397 to your computer and use it in GitHub Desktop.
Nginx God config
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
God.watch do |w| | |
w.name = "nginx" | |
w.interval = 30.seconds | |
w.start = "/etc/init.d/nginx start" | |
w.stop = "/etc/init.d/nginx stop" | |
w.restart = "/etc/init.d/nginx restart" | |
w.start_grace = 10.seconds | |
w.restart_grace = 10.seconds | |
w.pid_file = "/var/run/nginx.pid" | |
# Cleanup the pid file (this is needed for processes running as a daemon). | |
w.behavior(:clean_pid_file) | |
# Conditions under which to start the process | |
w.start_if do |start| | |
start.condition(:process_running) do |c| | |
c.interval = 5.seconds | |
c.running = false | |
end | |
start.condition(:process_exits) | |
end | |
# Conditions under which to restart the process | |
w.restart_if do |restart| | |
restart.condition(:memory_usage) do |c| | |
c.above = 150.megabytes | |
c.times = [3, 5] # 3 out of 5 intervals | |
end | |
restart.condition(:cpu_usage) do |c| | |
c.above = 50.percent | |
c.times = 5 | |
end | |
end | |
w.lifecycle do |on| | |
on.condition(:flapping) do |c| | |
c.to_state = [:start, :restart] | |
c.times = 5 | |
c.within = 5.minute | |
c.transition = :unmonitored | |
c.retry_in = 10.minutes | |
c.retry_times = 5 | |
c.retry_within = 2.hours | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment