1 ENV['GOD_TEST_RAILS_ROOT'] || abort("Set a rails root for testing in an environment variable called GOD_TEST_RAILS_ROOT")
3 RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
8 w.name = "local-#{port}"
10 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -p #{port} -d"
11 w.restart = "mongrel_rails restart -P ./log/mongrel.pid -c #{RAILS_ROOT}"
12 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.megabytes
46 on.condition(:cpu_usage) do |c|
52 on.condition(:http_response_code) do |c|
57 c.timeout = 10.seconds