Skip to content

Instantly share code, notes, and snippets.

@cismous
Last active August 29, 2015 14:14
Show Gist options
  • Save cismous/61af3a03efebdd0b4ee6 to your computer and use it in GitHub Desktop.
Save cismous/61af3a03efebdd0b4ee6 to your computer and use it in GitHub Desktop.
node server
#!/bin/sh
# Provides: cismous
# Description: starts node app when system startup
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/cismous/.local/bin
DAEMON=/usr/bin/node
APPPATH=/home/cismous/www/chair
LOGPATH=/home/cismous/www/chair/logs
NAME=nodeapp
PID=/tmp/forever.pid
test -x $DAEMON || exit 0
do_start() {
forever start -l $LOGPATH/forever.log -o $LOGPATH/out.log -e $LOGPATH/err.log --pidFile $PID -a $APPPATH/app.js
}
do_stop() {
forever stop --pidFile $PID $APPPATH/app.js
}
do_restart() {
forever restart -l $LOGPATH/forever.log -o $LOGPATH/out.log -e $LOGPATH/err.log --pidFile $PID -a $APPPATH/app.js
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
stopall)
forever stopall --pidFile $PID
;;
restartall)
forever stop --pidFile $PID
forever restart --pidFile $PID
;;
restart|reload)
do_restart
;;
*)
echo "Usage: $NAME {start|stop|stopall|restart|restartall|reload}" >&2
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment