Skip to content

Instantly share code, notes, and snippets.

@1st8
Created July 17, 2012 08:47
Show Gist options
  • Save 1st8/3128135 to your computer and use it in GitHub Desktop.
Save 1st8/3128135 to your computer and use it in GitHub Desktop.
God process monitoring + Upstart + rbenv
description "God Process Monitoring"
author "Christoph Geschwind <christoph@mixxt.net>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn # respawn the service if it dies
respawn limit 5 10 # stop respawning if it fails 5 times in 10 seconds
pre-start script
mkdir -p /var/run/god # create gods pid directory, you might not need this
end script
script
. /etc/profile.d/phoenix.sh # load environment variables, you might replace or not need this at all
export RBENV_ROOT="/usr/local/rbenv" # set required rbenv variable
# launch god via rbenv NOT daemonized, loads a centralized config in /etc/god.conf
exec /usr/local/rbenv/bin/rbenv exec god -D -c /etc/god.conf
# could not get this working without the -D flag and any expect behaviour,
# see http://upstart.ubuntu.com/cookbook/#expect for more information
# this paragraph supported my decision:
# "If your daemon has a "don't daemonize" or "run in the foreground" mode, then it's much simpler to use that and not run
# with fork following. One issue with that though, is that Upstart will emit the started JOB=yourjob event as soon as it has
# executed your daemon, which may be before it has had time to listen for incoming connections or fully initialize."
end script
@jpterry
Copy link

jpterry commented Jul 16, 2013

Just what I was looking for. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment