Skip to content

Instantly share code, notes, and snippets.

@zaiddabaeen
Last active August 29, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaiddabaeen/5bcf60d47ae0c903cfd5 to your computer and use it in GitHub Desktop.
Save zaiddabaeen/5bcf60d47ae0c903cfd5 to your computer and use it in GitHub Desktop.
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