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 = ENV['GOD_TEST_RAILS_ROOT']
11 w.interval = 5.seconds
12 w.start = "mongrel_rails start -P #{RAILS_ROOT}/log/mongrel.pid -c #{RAILS_ROOT} -d"
13 w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/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")
18 # clean pid files before start if necessary
19 w.behavior(:clean_pid_file)
21 # determine the state on startup
22 w.transition(:init, { true => :up, false => :start }) do |on|
23 on.condition(:process_running) do |c|
28 # determine when process has finished starting
29 w.transition([:start, :restart], :up) do |on|
30 on.condition(:process_running) do |c|
35 on.condition(:tries) do |c|
41 # start if process is not running
42 w.transition(:up, :start) do |on|
43 on.condition(:process_exits)
46 # restart if memory or cpu is too high
47 w.transition(:up, :restart) do |on|
48 on.condition(:memory_usage) do |c|
50 c.above = 50.megabytes
54 on.condition(:cpu_usage) do |c|
60 on.condition(:http_response_code) do |c|
65 c.timeout = 10.seconds
72 on.condition(:flapping) do |c|
73 c.to_state = [:start, :restart]
76 c.transition = :unmonitored
77 c.retry_in = 10.minutes
79 c.retry_within = 2.hours