Skip to content

Instantly share code, notes, and snippets.

@alexbain
Last active December 10, 2015 09:49
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 alexbain/4417002 to your computer and use it in GitHub Desktop.
Save alexbain/4417002 to your computer and use it in GitHub Desktop.
Upstart configuration template for a NodeJS app on Ubuntu 12.04LTS. Expected to live in ``/etc/init``
# /etc/init/APP.com.conf
description "APP.com"
start on runlevel [2345]
stop on runlevel [016]
# Restart when job dies
respawn
# Give up restart after 5 respawns in 60 seconds
respawn limit 5 60
script
echo $$ > /var/run/APP.com.pid
exec sudo -u deploy /usr/local/bin/node /home/deploy/www/APP.com/app.js 2>&1 >> /home/deploy/logs/APP.com.upstart.log
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /home/deploy/logs/APP.com.upstart.log
end script
pre-stop script
rm /var/run/alexandtala.com.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /home/deploy/logs/APP.com.upstart.log
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment