documentation updates
[god.git] / test / configs / real.rb
blobd9f1a63126560afb5d2a43a13e61dcb839cedaf2
1 if $0 == __FILE__
2   require File.join(File.dirname(__FILE__), *%w[.. .. lib god])
3 end
5 RAILS_ROOT = "/Users/tom/dev/powerset/querytopia"
7 God.meddle do |god|
8   god.watch do |w|
9     w.name = "local-3000"
10     w.interval = 5 # seconds
11     w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -d"
12     w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
13     w.grace = 30
14     
15     pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
16     
17     # clean pid files before start if necessary
18     w.behavior(:clean_pid_file) do |b|
19       b.pid_file = pid_file
20     end
21   
22     # start if process is not running
23     w.start_if do |start|
24       # start.condition(:process_exits) do |c|
25       #   c.pid_file = pid_file
26       # end
27       
28       start.condition(:process_not_running) do |c|
29         c.pid_file = pid_file
30       end
31     end
32     
33     # restart if memory or cpu is too high
34     w.restart_if do |restart|
35       restart.condition(:memory_usage) do |c|
36         c.interval = 20
37         c.pid_file = pid_file
38         c.above = (50 * 1024) # 50mb
39         c.times = [3, 5]
40       end
41       
42       restart.condition(:cpu_usage) do |c|
43         c.interval = 10
44         c.pid_file = pid_file
45         c.above = 10 # percent
46         c.times = [3, 5]
47       end
48     end
49   end
50   
51   # clear old session files
52   # god.watch do |w|
53   #   w.name = "local-session-cleanup"
54   #   w.start = lambda do
55   #     Dir["#{RAILS_ROOT}/tmp/sessions/ruby_sess.*"].select do |f|
56   #       File.mtime(f) < Time.now - (7 * 24 * 60 * 60)
57   #     end.each { |f| File.delete(f) }
58   #   end
59   #   
60   #   w.start_if do |start|
61   #     start.condition(:always)
62   #   end
63   # end
64 end