Created
October 15, 2014 15:47
-
-
Save pluma/b364c1b34304a9e648c3 to your computer and use it in GitHub Desktop.
Node init.d script with naught.
This file contains 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 | |
NAME=webapp | |
IPC=/var/run/naught/$NAME.ipc | |
DESC="my application server" | |
WORKERS=2 | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
naught start --worker-count $WORKERS --ipc-file $IPC --log /var/log/$NAME/naught.log --stdout /var/log/$NAME/stdout.log --stderr /var/log/$NAME/stderr.log --cwd /srv/$NAME/ /srv/$NAME/index.js | |
chown root:root $IPC | |
echo "done." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
naught stop --timeout 60 $IPC | |
echo "done." | |
;; | |
reload) | |
echo -n "Reloading $DESC: " | |
naught deploy --timeout 60 $IPC | |
echo "done." | |
;; | |
status) | |
naught status $IPC | |
exit $? | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
naught deploy --timeout 60 $IPC | |
if [ $? -ne "0" ]; then | |
$0 stop | |
$0 start | |
exit $? | |
fi | |
echo "done." | |
;; | |
*) | |
echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment