Created
October 26, 2009 18:03
-
-
Save wfarr/218876 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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