Skip to content

Instantly share code, notes, and snippets.

@misteral
Forked from 1st8/gist:3128135
Created September 25, 2013 01:54
Show Gist options
  • Save misteral/6694186 to your computer and use it in GitHub Desktop.
Save misteral/6694186 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment