Skip to content

Instantly share code, notes, and snippets.

@pluma pluma/webapp
Created Oct 15, 2014

Embed
What would you like to do?
Node init.d script with naught.
#!/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
You can’t perform that action at this time.