Created
June 28, 2014 22:21
-
-
Save fire/94051784373ece74b983 to your computer and use it in GitHub Desktop.
Groovebasin upstart script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!upstart | |
# using upstart http://upstart.ubuntu.com/getting-started.html and node forever https://github.com/nodejitsu/forever/ | |
# to run server | |
# redhat has additional sudo restrictions, you must comment out 'Default requiretty' from /etc/sudoers | |
#startup monitoring script derived from http://stackoverflow.com/questions/11084279/node-js-setup-for-easy-deployment-and-updating | |
description "node.js groovebasin server" | |
author "fire" | |
env PROGRAM_NAME="nodejs" | |
env FULL_PATH="/home/groove/groovebasin/" | |
env FILE_NAME="lib/server.js" | |
env NODE_PATH="/usr/bin/nodejs" | |
env USERNAME="groove" | |
start on startup | |
stop on shutdown | |
script | |
export HOME="/home/groove/" | |
export NODE_ENV=production #development/staging/production | |
echo $$ > /var/run/$PROGRAM_NAME.pid | |
cd $FULL_PATH | |
exec sudo -u $USERNAME taskset -c 0,1 $NODE_PATH $FULL_PATH/$FILE_NAME >> /var/log/$PROGRAM_NAME.sys.log 2>&1 | |
#exec $NODE_PATH $FULL_PATH/$FILE_NAME >> /var/log/$PROGRAM_NAME.sys.log 2>&1 | |
end script | |
pre-start script | |
# Date format same as (new Date()).toISOString() for consistency | |
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/$PROGRAM_NAME.sys.log | |
end script | |
pre-stop script | |
rm /var/run/$PROGRAM_NAME.pid | |
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/$PROGRAM_NAME.sys.log | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment