Skip to content

Instantly share code, notes, and snippets.

@andrusha
Created January 24, 2013 17:42
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 andrusha/4625608 to your computer and use it in GitHub Desktop.
Save andrusha/4625608 to your computer and use it in GitHub Desktop.
God supervisor example config for node.js app
#!/usr/bin/env ruby
God.watch do |w|
w.group = "hubot_group"
w.name = "hubot"
w.interval = 1.seconds
w.env = { 'NODE_ENV' => 'production'}
w.start = "node ..."
w.start_grace = 5.seconds
w.restart_grace = 5.seconds
w.log = "/var/www/..."
w.keepalive(:memory_max => 1024.megabytes, :cpu_max => 80.percent)
# 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
c.interval = 5.seconds
end
# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
c.interval = 5.seconds
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment