moved to timer based poll mechanism
[god.git] / examples / gravatar.god
blobce5d2692acbba16d00b063a742d89435239f0ca6
1 # This is the actual config file used to keep the mongrels of
2 # gravatar.com running.
4 RAILS_ROOT = "/var/www/gravatar2/current"
6 God.meddle do |god|
7   god.interval = 30 # seconds
9   %w{8200 8201 8202}.each do |port|
10     god.watch do |w|
11       w.name = "gravatar2-mongrel-#{port}"
12       w.start = "mongrel_rails cluster::start --only #{port} -c #{RAILS_ROOT}"
13       w.stop = "mongrel_rails cluster::stop --only #{port} -c #{RAILS_ROOT}"
14       
15       pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
16       
17       w.behavior(:clean_pid_file) do |b|
18         b.pid_file = pid_file
19       end
21       w.start_if do |start|
22         start.condition(:process_not_running) do |c|
23           c.pid_file = pid_file
24         end
25       end
26       
27       w.restart_if do |restart|
28         restart.condition(:memory_usage) do |c|
29           c.pid_file = pid_file
30           c.above = (150 * 1024) # 150mb
31           c.times = [3, 5] # 3 out of 5 intervals
32         end
33       
34         restart.condition(:cpu_usage) do |c|
35           c.pid_file = pid_file
36           c.above = 50 # percent
37           c.times = 5
38         end
39       end
40     end
41   end
42 end