Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created October 26, 2009 18:03
Show Gist options
  • Select an option

  • Save wfarr/218876 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/218876 to your computer and use it in GitHub Desktop.
God.watch do |w|
w.name = "mongod"
w.interval = 30.seconds
w.start = "rake -f #{RAILS_ROOT}/Rakefile mongodb:start"
w.stop = "killall mongod"
w.env = { "RAILS_ENV" => "development" }
w.uid = 'rails'
w.gid = 'rails'
w.pid_file = File.join(RAILS_ROOT, 'config/mongod.lock')
# clean pid files before start if necessary
w.behavior(:clean_pid_file)
# 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_exits)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment