fix sample configs, add announce template
[god.git] / examples / gravatar.god
blob6109f48b4313a6d5833cebdbd119d7c4dd4c6b01
1 # run with:  god start -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_not_running) do |c|
27           c.interval = 5 # seconds
28           c.pid_file = pid_file
29         end
30       end
31       
32       w.restart_if do |restart|
33         restart.condition(:memory_usage) do |c|
34           c.pid_file = pid_file
35           c.above = (150 * 1024) # 150mb
36           c.times = [3, 5] # 3 out of 5 intervals
37         end
38       
39         restart.condition(:cpu_usage) do |c|
40           c.pid_file = pid_file
41           c.above = 50 # percent
42           c.times = 5
43         end
44       end
45     end
46   end
47 end