forked from crjens/PiPowerMeter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-server.sh
More file actions
42 lines (38 loc) · 1.11 KB
/
node-server.sh
File metadata and controls
42 lines (38 loc) · 1.11 KB
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
#! /bin/sh
# /etc/init.d/node-server
### BEGIN INIT INFO
# Provides: node-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# change this to wherever your node app lives #
path_to_node_app=/home/pi/app/server.js
APP_DIR=/home/pi/app
SERVER_JS_FILE=/home/pi/app/server.js
FOREVER=forever
USER=pi
OUT=/home/pi
NODE=/usr/bin/node
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "* starting node-server * "
echo "* starting node-server * [`date`]" >> /var/log/node-server.log
cd /home/pi/app
# sudo $NODE $SERVER_JS_FILE >> /dev/null 2>&1&
sudo $FOREVER start --workingDir $APP_DIR -a -o /dev/null -e $OUT/nodejs.err.log --killSignal=SIGTERM $SERVER_JS_FILE
;;
stop)
echo "* stopping node-server * "
echo "* stopping node-server * [`date`]" >> /var/log/node-server.log
# killall $NODE
sudo $FOREVER stop --killSignal=SIGTERM $SERVER_JS_FILE
;;
*)
echo "Usage: /etc/init.d/node-server {start|stop}"
exit 1
;;
esac
exit 0