2 require File.join(File.dirname(__FILE__), *%w[.. .. lib god])
5 ENV['GOD_TEST_RAILS_ROOT'] || abort("Set a rails root for testing in an environment variable called GOD_TEST_RAILS_ROOT")
7 RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
12 # g.pid_file_directory =
17 puts "Notifying: #{str}"
23 w.interval = 5.seconds
24 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -p 3001 -d"
25 w.restart = "mongrel_rails restart -P ./log/mongrel.pid -c #{RAILS_ROOT}"
26 w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
27 w.restart_grace = 5.seconds
28 w.stop_grace = 5.seconds
33 w.pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
35 # clean pid files before start if necessary
36 w.behavior(:clean_pid_file)
38 w.behavior(:notify_when_flapping) do |b|
40 b.seconds = 60.seconds
41 b.notifier = SimpleNotifier
44 # determine the state on startup
45 w.transition(:init, { true => :up, false => :start }) do |on|
46 on.condition(:process_running) do |c|
51 # determine when process has finished starting
52 w.transition([:start, :restart], :up) do |on|
53 on.condition(:process_running) do |c|
58 # start if process is not running
59 w.transition(:up, :start) do |on|
60 on.condition(:process_exits)
63 # restart if memory or cpu is too high
64 w.transition(:up, :restart) do |on|
65 on.condition(:memory_usage) do |c|
67 c.above = 50.megabytes
71 on.condition(:cpu_usage) do |c|