Newer
Older
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: node-red
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the node-red server
### END INIT INFO
NAME=node-red
DAEMON=node-red-pi
SETTINGS=/usr/share/node-red/settings.js
DAEMON_ARGS="--max-old-space-size=128 -s ${SETTINGS}"
LOG_DIR="/var/log/node-red"
LOG="${LOG_DIR}/node-red.log"
PID=/run/node-red.pid
if [[ ! -e ${LOG_DIR} ]]; then
mkdir -p ${LOG_DIR}
fi
case "$1" in
start)
echo -n "Starting $NAME: "
start-stop-daemon --start --quiet --background --make-pidfile \
--pidfile $PID --name $NAME --startas /bin/bash -- -c "exec $DAEMON $DAEMON_ARGS > $LOG 2>&1"
echo "$NAME."
;;
stop)
echo -n "Stopping $NAME: "
start-stop-daemon --stop --quiet --name $NAME --pidfile $PID \
--retry 30 --signal INT
rm -f $PID
echo "$NAME."
;;
restart)
echo -n "Restarting $NAME: "
$0 stop
sleep 1
$0 start
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0