2 require File.join(File.dirname(__FILE__), *%w[.. .. lib god])
5 RAILS_ROOT = "/Users/tom/dev/git/helloworld"
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}"
14 pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
16 # clean pid files before start if necessary
17 w.behavior(:clean_pid_file) do |b|
21 # start if process is not running
23 start.condition(:process_running) do |c|
29 # restart if memory or cpu is too high
30 w.restart_if do |restart|
31 restart.condition(:memory_usage) do |c|
34 c.above = (50 * 1024) # 50mb
38 restart.condition(:cpu_usage) do |c|
41 c.above = 10 # percent
47 # clear old session files
49 # w.name = "local-session-cleanup"
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) }
56 # w.start_if do |start|
57 # start.condition(:always)