Last active
August 29, 2015 14:21
-
-
Save keepitsimple/73cea7ee2b517035605b to your computer and use it in GitHub Desktop.
Upstart config file for node.js service
This file contains hidden or 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
#znapi.conf | |
description "node.js zn api" | |
env FULL_PATH="/home/zn/app.prod" | |
env NODE_PATH="/usr/bin/node" | |
env LOG="/var/log/znapi.log" | |
env PIDFILE="/var/run/znapi.pid" | |
# Start up when the system hits any normal runlevel, and | |
start on filesystem or runlevel [2345] | |
#start when mongod started | |
#start on started mongod | |
# shuts down when the system goes to shutdown or reboot. | |
stop on runlevel [06] | |
respawn | |
respawn limit 50 5 | |
pre-start script | |
# check that log file exist or create it | |
test -f $LOG || { touch $LOG; chown zn:zn $LOG; } | |
# Date format same as (new Date()).toISOString() for consistency | |
echo "[`date`] (sys) Starting" >> $LOG | |
end script | |
script | |
export NODE_ENV=production | |
#echo $$ > /var/run/znapi.pid | |
#cd $FULL_PATH | |
#exec sudo -u zn sh -c "$NODE_PATH server.js >> $LOG 2>&1" | |
#exec $NODE_PATH server.js >> $LOG 2>&1 | |
exec start-stop-daemon --start -m -p $PIDFILE -c zn -d $FULL_PATH -x server.js >> $LOG 2>&1 | |
end script | |
pre-stop script | |
rm $PIDFILE | |
echo "[`date`] (sys) Stopping" >> $LOG | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment