added cpu_usage condition and local.god example
[god.git] / test / configs / real.rb
blob79ff14a79b92c2ffeb5b0d227c55dbf25fbce33b
1 if $0 == __FILE__
2   require File.join(File.dirname(__FILE__), *%w[.. .. lib god])
3 end
5 RAILS_ROOT = "/Users/tom/dev/gravatar2"
7 God.meddle do |god|
8   god.interval = 5 # seconds
9   
10   god.watch do |w|
11     w.name = "local-3000"
12     w.cwd = RAILS_ROOT
13     w.start = "mongrel_rails start -P ./log/mongrel.pid -d"
14     w.stop = "mongrel_rails stop -P ./log/mongrel.pid"
15     w.grace = 5
16     
17     pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
18   
19     w.start_if do |start|
20       start.condition(:process_not_running) do |c|
21         c.pid_file = pid_file
22       end
23     end
24     
25     w.restart_if do |restart|
26       restart.condition(:memory_usage) do |c|
27         c.pid_file = pid_file
28         c.above = (50 * 1024) # 50mb
29         c.times = [3, 5]
30       end
31       
32       restart.condition(:cpu_usage) do |c|
33         c.pid_file = pid_file
34         c.above = 10 # percent
35         c.times = [3, 5]
36       end
37     end
38   end
39 end