Created
July 8, 2011 18:55
-
-
Save joemccann/1072521 to your computer and use it in GitHub Desktop.
General init.d script on Debian for node apps.
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
#! /bin/sh | |
# /etc/init.d/myapp | |
# | |
# Don't forget to reload init.d: | |
# update-rc.d myapp defaults | |
APP='myapp' | |
case "$1" in | |
start) | |
NODE_ENV=production node /var/www/$APP/app.js 80 & | |
echo $! > $APP.node.pid | |
;; | |
stop) | |
cat $APP.node.pid | xargs kill | |
;; | |
restart) | |
cat $APP.node.pid | xargs kill | |
NODE_ENV=production node /var/www/$APP/app.js 80 & | |
echo $! > $APP.node.pid | |
;; | |
*) | |
echo "Usage: /etc/init.d/appname {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment