fix tests to work with reasonable at_exit, restrict notifications to be sent only...
[god.git] / examples / gravatar.god
blobb52c147ad2517eaeb63de7f061bc5c519b50dcd6
1 # run with:  god -c /path/to/gravatar.god
2
3 # This is the actual config file used to keep the mongrels of
4 # gravatar.com running.
6 RAILS_ROOT = "/var/www/gravatar2/current"
8 %w{8200 8201 8202}.each do |port|
9   God.watch do |w|
10     w.name = "gravatar2-mongrel-#{port}"
11     w.interval = 30.seconds
12     w.start = "mongrel_rails cluster::start --only #{port} \
13       -C #{RAILS_ROOT}/config/mongrel_cluster.yml"
14     w.stop = "mongrel_rails cluster::stop --only #{port} \
15       -C #{RAILS_ROOT}/config/mongrel_cluster.yml"
16     w.grace = 10.seconds
17     
18     pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
19     
20     w.behavior(:clean_pid_file)
22     w.start_if do |start|
23       start.condition(:process_running) do |c|
24         c.interval = 5.seconds
25         c.running = false
26       end
27     end
28     
29     w.restart_if do |restart|
30       restart.condition(:memory_usage) do |c|
31         c.above = 150.megabytes
32         c.times = [3, 5] # 3 out of 5 intervals
33       end
34     
35       restart.condition(:cpu_usage) do |c|
36         c.above = 50.percent
37         c.times = 5
38       end
39     end
40   end
41 end