Skip to content

Instantly share code, notes, and snippets.

@channprj
Last active January 31, 2016 13:19
Show Gist options
  • Save channprj/695f8216aabd81c12255 to your computer and use it in GitHub Desktop.
Save channprj/695f8216aabd81c12255 to your computer and use it in GitHub Desktop.
Ghost blog booting script with forever package.
#!/bin/sh
### BEGIN INIT INFO
# Provides: blog
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
USER="blog"
APP="/home/blog/ghost/index.js"
LOG="/var/log/ghost/server.log"
stop() {
sudo su - $USER -c "source ~/.zshrc; NODE_ENV=production forever stop $APP;"
# sudo su - $USER -c "NODE_ENV=production forever stop $APP"
}
start() {
sudo su - $USER -c "source ~/.zshrc; NODE_ENV=production forever start --append -l $LOG -o $LOG -e $LOG $APP;"
# sudo su - $USER -c "NODE_ENV=production forever start --append -l $LOG -o $LOG -e $LOG $APP"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment