1 # This example shows how you might keep a local development Rails server up
2 # and running on your Mac.
5 # god -c /path/to/events.god
7 RAILS_ROOT = "/Users/tom/dev/git/helloworld"
11 w.interval = 5.seconds
12 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -d"
13 w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
14 w.pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
15 w.log = File.join(RAILS_ROOT, "log/commands.log")
17 # clean pid files before start if necessary
18 w.behavior(:clean_pid_file)
20 # determine the state on startup
21 w.transition(:init, { true => :up, false => :start }) do |on|
22 on.condition(:process_running) do |c|
27 # determine when process has finished starting
28 w.transition([:start, :restart], :up) do |on|
29 on.condition(:process_running) do |c|
34 on.condition(:tries) do |c|
40 # start if process is not running
41 w.transition(:up, :start) do |on|
42 on.condition(:process_exits)
45 # restart if memory or cpu is too high
46 w.transition(:up, :restart) do |on|
47 on.condition(:memory_usage) do |c|
49 c.above = 50.megabytes
53 on.condition(:cpu_usage) do |c|
59 on.condition(:http_response_code) do |c|
64 c.timeout = 10.seconds
71 on.condition(:flapping) do |c|
72 c.to_state = [:start, :restart]
75 c.transition = :unmonitored
76 c.retry_in = 10.minutes
78 c.retry_within = 2.hours