1 # This example shows how you might keep a local development Rails server up
2 # and running on your Mac.
5 # god start -c /path/to/local.god
7 RAILS_ROOT = "/Users/tom/dev/powerset/querytopia"
12 w.interval = 5 # seconds
13 w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -d"
14 w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}"
17 pid_file = File.join(RAILS_ROOT, "log/mongrel.pid")
19 # clean pid files before start if necessary
20 w.behavior(:clean_pid_file) do |b|
24 # start if process is not running
26 start.condition(:process_exits) do |c|
31 # restart if memory or cpu is too high
32 w.restart_if do |restart|
33 restart.condition(:memory_usage) do |c|
35 c.above = (50 * 1024) # 50mb
39 restart.condition(:cpu_usage) do |c|
41 c.above = 10 # percent
47 # clear old session files
49 w.name = "local-session-cleanup"
50 w.interval = 60 # seconds
51 w.cwd = File.join(RAILS_ROOT, 'tmp/sessions')
53 Dir['ruby_sess.*'].select { |f| File.mtime(f) < Time.now - (7 * 24 * 60 * 60) }.each { |f| File.delete(f) }
57 start.condition(:always)