Created
May 13, 2012 17:23
-
-
Save rla/2689368 to your computer and use it in GitHub Desktop.
Node.JS startup scripts
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
start.sh: | |
#!/usr/bin/env bash | |
if [ -e 'master.pid' ] | |
then | |
echo 'Master PID file exists, cannot start.' | |
exit 1 | |
fi | |
NODE_ENV=production /usr/local/bin/node app.js &>> server.log & | |
stop.sh: | |
#!/usr/bin/env bash | |
if [ -e 'master.pid' ] | |
then | |
kill `cat master.pid` | |
fi | |
init script: | |
#!/usr/bin/env bash | |
case "$1" in | |
'start') | |
su - kamweb -c 'cd /home/kamweb && ./start.sh' ;; | |
'stop') | |
su - kamweb -c 'cd /home/kamweb && ./stop.sh' ;; | |
*) | |
echo "Usage: $0 { start | stop }" ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment