
Untitled
By: a guest on
May 17th, 2012 | syntax:
None | size: 0.82 KB | hits: 10 | expires: Never
#!/bin/sh
set -e
DESC="node.js test"
NAME="test.js"
DAEMON=/home/zz/test.js
SCRIPTNAME=/home/zz/test.init
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
#. /etc/default/$NAME
WDIR=/home/zz
RUNAS=zz
# Function that starts the daemon/service.
d_start() {
cd $WDIR &&
su $RUNAS node test.js > /dev/null 2>&1 &
}
# Function that stops the daemon/service.
d_stop() {
killall "node test.js" > /dev/null 2>&1 || true
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0