Skip to content

Instantly share code, notes, and snippets.

@helxsz
Last active December 28, 2015 13:49
Show Gist options
  • Save helxsz/7510746 to your computer and use it in GitHub Desktop.
Save helxsz/7510746 to your computer and use it in GitHub Desktop.
node_app_start.sh
#! /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