Merge branch 'fork_exec' of git://208.76.47.25
[god.git] / examples / gravatar.god
blobb2da97ad3bb2329e418ff5d893028da50be0fa0b
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 God.meddle do |god|
9   %w{8200 8201 8202}.each do |port|
10     god.watch do |w|
11       w.name = "gravatar2-mongrel-#{port}"
12       w.interval = 30 # seconds
13       w.start = "mongrel_rails cluster::start --only #{port} \
14         -C #{RAILS_ROOT}/config/mongrel_cluster.yml"
15       w.stop = "mongrel_rails cluster::stop --only #{port} \
16         -C #{RAILS_ROOT}/config/mongrel_cluster.yml"
17       w.grace = 10 # seconds
18       
19       pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
20       
21       w.behavior(:clean_pid_file) do |b|
22         b.pid_file = pid_file
23       end
25       w.start_if do |start|
26         start.condition(:process_running) do |c|
27           c.interval = 5 # seconds
28           c.running = false
29           c.pid_file = pid_file
30         end
31       end
32       
33       w.restart_if do |restart|
34         restart.condition(:memory_usage) do |c|
35           c.pid_file = pid_file
36           c.above = (150 * 1024) # 150mb
37           c.times = [3, 5] # 3 out of 5 intervals
38         end
39       
40         restart.condition(:cpu_usage) do |c|
41           c.pid_file = pid_file
42           c.above = 50 # percent
43           c.times = 5
44         end
45       end
46     end
47   end
48 end