forked from sfu/node-lti-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.d.ltiserver.example
65 lines (59 loc) · 1.45 KB
/
init.d.ltiserver.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
# node-lti-server Startup script for the library reserves LTI server
#
# chkconfig: 3 4 5
#
# processname: node-lti-server
# pidfile: /var/nodeapps/node-lti-server/shared/pids/node-lti-server.pid
. /etc/rc.d/init.d/functions
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
NODE='/usr/local/bin/node'
PORT=3001
APP_DIR='/var/nodeapps/node-lti-server/current'
SHARED_DIR='/var/nodeapps/node-lti-server/shared'
SCRIPT="$APP_DIR/app.js"
PIDFILE="$SHARED_DIR/pids/node-lti-server.pid"
LOGFILE="$SHARED_DIR/log/node-lti-server.log"
RUN_AS_USER=nodeuser
start() {
if [ -f $PIDFILE ] ; then
PID=$(cat $PIDFILE)
echo "$PIDFILE exists, node-lti-server is already running or crashed ($PID)"
else
echo -n "Starting node-lti-server..."
NODE_ENV=production PORT=$PORT $NODE $SCRIPT >> $LOGFILE 2>&1 &
echo_success || echo_failure
echo $! > $PIDFILE
chown $RUN_AS_USER $PIDFILE
fi
echo
}
stop() {
echo -n "Stopping node-lti-server..."
if [ ! -f $PIDFILE ] ; then
echo -n " process is not running"
echo_failure
else
PID=$(cat $PIDFILE)
echo -n " killing $PID "
kill $PID
while [ -x ${PIDFILE} ] ; do
sleep 1
done
rm -rf $PIDFILE
echo_success || echo_failure
fi
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
esac