-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoflo.init
36 lines (29 loc) · 967 Bytes
/
noflo.init
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
#!/bin/bash
# /etc/init.d/noflo.sh
# needs the tool 'timeout': https://github.com/pshved/timeout
# Starts and stops the Noflo service and kills the process if it needs more
# than MEMLIMIT kilobytes of memory.
NODE=/opt/node/bin/node
NOFLO_PROJECT_ROOT=/home/pi/Projects/ingress-table
SERVER_JS_FILE=$NOFLO_PROJECT_ROOT/node_modules/.bin/noflo
NOFLO_GRAPH=$NOFLO_PROJECT_ROOT/graphs/main.json
USER=pi
OUT=/home/pi/nodejs.log
PIDFILE=/var/run/noflo.pid
TIMEOUT_PATH=/home/pi/timeout
MEMLIMIT=400000
COFFEE_CACHE_DIR=/tmp/coffee-cache
case "$1" in
start)
echo "starting node: $NODE $SERVER_JS_FILE"
cd $NOFLO_PROJECT_ROOT
(while true; do sudo -u $USER COFFEE_CACHE_DIR=$COFFEE_CACHE_DIR NOFLO_PROJECT_ROOT=$NOFLO_PROJECT_ROOT $TIMEOUT_PATH -m $MEMLIMIT $NODE $SERVER_JS_FILE --cache $NOFLO_GRAPH > $OUT 2>$OUT ; sleep 10; done) &
echo $! > $PIDFILE
;;
stop)
kill `cat $PIDFILE`
;;
*)
echo "usage: $0 (start|stop)"
esac
exit 0