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