Skip to content

Instantly share code, notes, and snippets.

@jtomaszewski
Created December 25, 2013 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtomaszewski/8119378 to your computer and use it in GitHub Desktop.
Save jtomaszewski/8119378 to your computer and use it in GitHub Desktop.
Watch websocket_rails server with God
RAILS_ROOT = File.expand_path('../', File.dirname(__FILE__))
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
God.watch do |w|
w.name = "websocket_rails"
w.start = "cd #{RAILS_ROOT} && bundle exec rake websocket_rails:start_server"
w.stop = "cd #{RAILS_ROOT} && bundle exec rake websocket_rails:stop_server"
w.pid_file = "#{RAILS_ROOT}/tmp/pids/websocket_rails.pid"
w.behavior(:clean_pid_file)
# w.keepalive
w.log = "#{RAILS_ROOT}/log/god.log"
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 30.seconds
c.running = false
end
end
w.lifecycle do |on|
on.condition(:flapping) do |c|
c.to_state = [:start, :restart]
c.times = 5
c.within = 5.minute
c.transition = :unmonitored
c.retry_in = 10.minutes
c.retry_times = 5
c.retry_within = 2.hours
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment