documentation updates
[god.git] / examples / gravatar.god
blob1e300c62c69c9210b9245962be8d95fc30beb103
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   %w{8200 8201 8202}.each do |port|
8     god.watch do |w|
9       w.name = "gravatar2-mongrel-#{port}"
10       w.interval = 30 # seconds
11       w.start = "mongrel_rails cluster::start --only #{port} -c #{RAILS_ROOT}"
12       w.stop = "mongrel_rails cluster::stop --only #{port} -c #{RAILS_ROOT}"
13       
14       pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
15       
16       w.behavior(:clean_pid_file) do |b|
17         b.pid_file = pid_file
18       end
20       w.start_if do |start|
21         start.condition(:process_not_running) do |c|
22           c.pid_file = pid_file
23         end
24       end
25       
26       w.restart_if do |restart|
27         restart.condition(:memory_usage) do |c|
28           c.pid_file = pid_file
29           c.above = (150 * 1024) # 150mb
30           c.times = [3, 5] # 3 out of 5 intervals
31         end
32       
33         restart.condition(:cpu_usage) do |c|
34           c.pid_file = pid_file
35           c.above = 50 # percent
36           c.times = 5
37         end
38       end
39     end
40   end
41 end