Created
October 28, 2015 06:44
-
-
Save lokesh-webonise/914e9725cea3406f5165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################### | |
#Set Env variables# | |
################### | |
USER=deploy | |
PIDFILE=/tmp/demo.pid | |
APPDIR=/var/www/demo-warehouse.weboapps.com/server/ | |
NODEENV=staging | |
DEAMON=/usr/bin/node | |
DEAMON_OPT=/var/www/demo-warehouse.weboapps.com/server/server.js | |
function start { | |
start-stop-daemon --start --oknodo --background --user $USER --chuid $USER -m -p $PIDFILE --chdir $APPDIR --exec /usr/bin/env NODE_ENV="`echo $NODEENV`" $DEAMON -- $DEAMON_OPT | |
} | |
function stop { | |
start-stop-daemon --stop --oknodo --user $USER --chuid $USER -p $PIDFILE --chdir $APPDIR --exec $DEAMON -- $DEAMON_OPT | |
} | |
case $1 in | |
start) | |
if [ -f $DEAMON_OPT ]; then | |
echo "starting Node service" | |
start | |
echo -e "Started [OK] \nNode service started with pid : `cat $PIDFILE`" | |
else | |
echo "Node service start failed" | |
echo "status returned $?" | |
fi | |
;; | |
stop) | |
if [ -f $PIDFILE ]; then | |
echo "shutting down Node service" | |
stop | |
echo "Node service stopped [OK]" | |
else | |
echo "Node service shutdown failed" | |
echo "status returned $?" | |
fi | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Use (start|stop|restart)"; | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment