Created
October 30, 2008 21:11
-
-
Save russ/21145 to your computer and use it in GitHub Desktop.
This file contains 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 = '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