app.god revision a543dfe944ecddb71e09c6c156afb3e471c78d6e
God.watch do |w|
w.name = 'resque'
w.start = 'cd ~/current && RAILS_ENV=production QUEUE=* rake resque:work'
# Restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.times = 2
end
end
# Determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end
# Determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
end
# Failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
end
end
# Start if process is not running
w.transition(:up, :start) do |on|
on.condition(:process_running) do |c|
c.running = false
end
end
end