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/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")
16 # clean pid files before start if necessary
17 w.behavior(:clean_pid_file)
19 # determine the state on startup
20 w.transition(:init, { true => :up, false => :start }) do |on|
21 on.condition(:process_running) do |c|
26 # determine when process has finished starting
27 w.transition([:start, :restart], :up) do |on|
28 on.condition(:process_running) do |c|
33 # start if process is not running
34 w.transition(:up, :start) do |on|
35 on.condition(:process_exits)
38 # restart if memory or cpu is too high
39 w.transition(:up, :restart) do |on|
40 on.condition(:memory_usage) do |c|
42 c.above = (50 * 1024) # 50mb
46 on.condition(:cpu_usage) do |c|
48 c.above = 10 # percent