Skip to content

Instantly share code, notes, and snippets.

@russ
Created October 30, 2008 21:11
Show Gist options
  • Save russ/21145 to your computer and use it in GitHub Desktop.
Save russ/21145 to your computer and use it in GitHub Desktop.
God.watch do |w|
w.name = 'starling'
w.interval = 5.seconds
w.start = 'starling'
w.stop = 'killall starling'
w.restart = 'killall starling && starling'
w.pid_file = '/var/run/starling.pid'
# determine when process has finished starting
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
end
end
# determine when process has finished starting
w.transition(:up, :start) do |on|
on.condition(:process_exits)
end
# lifecycle
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