Skip to content

Instantly share code, notes, and snippets.

@RaphaelAudet
Created October 27, 2014 15:44
Show Gist options
  • Save RaphaelAudet/e50e90ca92160c010ab0 to your computer and use it in GitHub Desktop.
Save RaphaelAudet/e50e90ca92160c010ab0 to your computer and use it in GitHub Desktop.
Monit wrapper script for FOREVER running GHOST
#!/bin/bash
export NODE_ENV=production
NAME="ghost-$NODE_ENV"
USER="node"
APP_ROOT="/var/www/ghost"
PID_FILE="/var/www/ghost/$NAME.pid "
export PATH=$PATH:
case $1 in
start)
/bin/su - $USER -c "cd $APP_ROOT && NODE_ENV=production forever start --uid=$NAME --pidFile=$PID_FILE -a -l $APP_ROOT/$NAME.log index.js"
;;
stop)
/bin/su - $USER -c "cd $APP_ROOT && NODE_ENV=production forever stop --uid=$NAME"
;;
status)
cat $PID_FILE
;;
*)
echo "usage: xyz {start|stop|status}" ;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment