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"
9 God::Contacts::Email.delivery_method = :smtp
10 God::Contacts::Email.server_settings = {}
12 God.contact(:email) do |c|
14 c.email = 'tom@powerset.com'
15 c.group = 'developers'
16 c.throttle = 30.minutes
21 w.interval = 5.seconds
22 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -d"
23 w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
24 w.pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
26 # clean pid files before start if necessary
27 w.behavior(:clean_pid_file)
29 # determine the state on startup
30 w.transition(:init, { true => :up, false => :start }) do |on|
31 on.condition(:process_running) do |c|
36 # determine when process has finished starting
37 w.transition([:start, :restart], :up) do |on|
38 on.condition(:process_running) do |c|
43 # start if process is not running
44 w.transition(:up, :start) do |on|
45 on.condition(:process_exits)
48 # restart if memory or cpu is too high
49 w.transition(:up, :restart) do |on|
50 on.condition(:memory_usage) do |c|
52 c.above = 50.megabytes
56 on.condition(:cpu_usage) do |c|
65 on.condition(:flapping) do |c|
66 c.to_state = [:start, :restart]
75 on.condition(:memory_usage) do |c|
77 c.above = 40.megabytes