Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created April 12, 2012 21:36
Show Gist options
  • Save nesquena/bc880685a27dfafef2bf to your computer and use it in GitHub Desktop.
Save nesquena/bc880685a27dfafef2bf to your computer and use it in GitHub Desktop.
Beanstalk and Rabbit God Configuration
God.watch do |w|
w.name = "beanstalkd"
w.interval = 30.seconds
w.start = "service beanstalkd start"
w.stop = "service beanstalkd stop"
w.restart = "service beanstalkd restart"
w.start_grace = 15.seconds
w.restart_grace = 15.seconds
w.pid_file = "/var/run/beanstalkd.pid"
w.log = "/var/log/god/god.log"
w.behavior(:clean_pid_file)
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 5.seconds
c.running = false
end
end
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 1500.megabytes
c.times = [3, 5] # 3 out of 5 intervals
c.notify = ['developers']
end
restart.condition(:cpu_usage) do |c|
c.above = 50.percent
c.times = 5
c.notify = ['developers']
end
end
# If this watch is started or restarted five times withing 5 minutes, then unmonitor it
#...then after ten minutes, monitor it again to see if it was just a temporary problem;
#if the process is seen to be flapping five times within two hours, then give up completely.
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
c.notify = ['developers']
end
end
end
God.watch do |w|
w.name = "rabbitmq"
w.interval = 30.seconds
w.start = "service rabbitmq-server start"
w.stop = "service rabbitmq-server stop"
w.restart = "service rabbitmq-server restart"
w.start_grace = 15.seconds
w.restart_grace = 15.seconds
w.pid_file = "/var/run/rabbitmq/pid"
w.log = "/var/log/god/god.log"
w.behavior(:clean_pid_file)
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 5.seconds
c.running = false
end
end
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 1500.megabytes
c.times = [3, 5] # 3 out of 5 intervals
c.notify = ['developers']
end
restart.condition(:cpu_usage) do |c|
c.above = 50.percent
c.times = 5
c.notify = ['developers']
end
end
# If this watch is started or restarted five times withing 5 minutes, then unmonitor it
#...then after ten minutes, monitor it again to see if it was just a temporary problem;
#if the process is seen to be flapping five times within two hours, then give up completely.
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
c.notify = ['developers']
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment