Instantly share code, notes, and snippets.

Embed
What would you like to do?
forever Ghost init.d script for CentOS 7.0

Copy the above file to /etc/init.d/.

Change the NODE_PATH variable to your index.js path. Change PATH variable to your which node

Usage: service ghost start service ghost stop service ghost restart

To set to run at boot: chkconfig --add ghost

#!/bin/sh
#
# Note runlevel 2345, 86 is the Start order and 85 is the Stop order
#
# chkconfig: 2345 86 85
# description: Description of the Service
#
# Below is the source function library, leave it be
. /etc/init.d/functions
# result of whereis forever or whereis node
export PATH=$PATH:/usr/bin
# result of whereis node_modules
NODE_PATH=/var/www/ghost/index.js
start(){
NODE_ENV=production forever start $NODE_PATH
}
stop(){
forever stop $NODE_PATH
}
restart(){
NODE_ENV=production forever restart $NODE_PATH
}
case "$1" in
start)
echo "Start service Ghost"
start
;;
stop)
echo "Stop service Ghost"
stop
;;
restart)
echo "Restart service Ghost"
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment