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"
12 w.interval = 5 # seconds
13 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -d"
14 w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
16 pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
18 # clean pid files before start if necessary
19 w.behavior(:clean_pid_file) do |b|
23 # determine the state on startup
24 w.transition(:init, { true => :up, false => :start }) do |on|
25 on.condition(:process_running) do |c|
31 # determine when process has finished starting
32 w.transition([:start, :restart], :up) do |on|
33 on.condition(:process_running) do |c|
39 # start if process is not running
40 w.transition(:up, :start) do |on|
41 on.condition(:process_exits) do |c|
46 # restart if memory or cpu is too high
47 w.transition(:up, :restart) do |on|
48 on.condition(:memory_usage) do |c|
51 c.above = (50 * 1024) # 50mb
55 on.condition(:cpu_usage) do |c|
58 c.above = 10 # percent