Skip to content

Instantly share code, notes, and snippets.

@ymorimo
Created February 10, 2011 08:50
Show Gist options
  • Save ymorimo/820161 to your computer and use it in GitHub Desktop.
Save ymorimo/820161 to your computer and use it in GitHub Desktop.
RAILS_ROOT = File.dirname(File.dirname(__FILE__))
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
def daemon_monitoring(w, options = {})
w.interval = 30.seconds
w.start = "#{options[:script]} start"
w.restart = "#{options[:script]} restart"
w.stop = "#{options[:script]} stop"
w.grace = 30.seconds
w.behavior(:clean_pid_file)
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 30.seconds
c.running = false
end
end
end
God.watch do |w|
script = "env RAILS_ENV=#{RAILS_ENV} #{RAILS_ROOT}/script/daemons/scheduler"
w.name = "scheduler"
w.group = "example_app"
w.pid_file = "#{RAILS_ROOT}/log/scheduler_daemon.pid"
daemon_monitoring(w, :script => script)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment