Skip to content

Instantly share code, notes, and snippets.

@saimonmoore
Created August 6, 2008 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saimonmoore/4239 to your computer and use it in GitHub Desktop.
Save saimonmoore/4239 to your computer and use it in GitHub Desktop.
ejabberdctl ||= "/usr/local/sbin/ejabberdctl"
God.watch do |w|
w.name = "ejabberd"
w.interval = 30.seconds # default
w.start = "#{ejabberdctl} start"
w.stop = "#{ejabberdctl} stop"
w.restart = "#{ejabberdctl} restart"
# w.start = "/etc/init.d/ejabberd start"
# w.stop = "/etc/init.d/ejabberd stop"
# w.restart = "/etc/init.d/ejabberd restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
# w.pid_file = "/usr/local/nginx/logs/nginx.pid"
# w.behavior(:clean_pid_file)
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 60.seconds
c.running = false
end
end
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 100.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
# lifecycle
w.lifecycle do |on|
on.condition(:flapping) do |c|
c.notify = "developers"
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