add --log-level to cli tool
[god.git] / test / configs / test.rb
blob00cdcb2777a912a9501a9576e7355c2f8ac69468
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']
5 port = 5000
7 God.watch do |w|
8   w.name = "local-#{port}"
9   w.interval = 5.seconds
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}"
13   w.group = 'mongrels'
14   w.pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
15   
16   # clean pid files before start if necessary
17   w.behavior(:clean_pid_file)
18   
19   # determine the state on startup
20   w.transition(:init, { true => :up, false => :start }) do |on|
21     on.condition(:process_running) do |c|
22       c.running = true
23     end
24   end
25   
26   # determine when process has finished starting
27   w.transition([:start, :restart], :up) do |on|
28     on.condition(:process_running) do |c|
29       c.running = true
30     end
31   end
33   # start if process is not running
34   w.transition(:up, :start) do |on|
35     on.condition(:process_exits)
36   end
37   
38   # restart if memory or cpu is too high
39   w.transition(:up, :restart) do |on|
40     on.condition(:memory_usage) do |c|
41       c.interval = 1
42       c.above = 50.megabytes
43       c.times = [3, 5]
44     end
45     
46     on.condition(:cpu_usage) do |c|
47       c.interval = 1
48       c.above = 10.percent
49       c.times = [3, 5]
50     end
51     
52     on.condition(:http_response_code) do |c|
53       c.host = 'localhost'
54       c.port = port
55       c.path = '/'
56       c.code_is_not = 200
57       c.timeout = 10.seconds
58       c.times = [3, 5]
59     end
60   end
61 end