annotate rlgwebd @ 192:addc4e3456c4

Begin adding systemd compatibility. The Makefile can be used to build and install rlgwebd. On systems with systemd, the unit file controls starting and stopping the service, and the shell script is not needed. The unit file uses KillMode=none because socat does not actually stop rlgwebd, it only asks it to stop and exits without waiting for a response. Until a better stopping method is introduced, this setting prevents systemd from killing all the rlgwebd processes as soon as socat exits.
author John "Elwin" Edwards
date Fri, 01 Jan 2016 16:11:34 -0500
parents 1a156a7746a7
children 5483d413a45b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
139
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
1 #!/bin/sh
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
2
141
1a156a7746a7 RLGWebD: use NODE_PATH to find modules.
John "Elwin" Edwards
parents: 139
diff changeset
3 NODE_PATH=/usr/lib/node_modules
139
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
4 LOGFILE=/var/local/rlgwebd/log
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
5 CTLSOCKET=/var/local/rlgwebd/ctl
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
6 RLGWEBDJS=./rlgwebd.js
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
7
141
1a156a7746a7 RLGWebD: use NODE_PATH to find modules.
John "Elwin" Edwards
parents: 139
diff changeset
8 export NODE_PATH
1a156a7746a7 RLGWebD: use NODE_PATH to find modules.
John "Elwin" Edwards
parents: 139
diff changeset
9
139
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
10 if [ $UID != 0 ]
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
11 then
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
12 echo "$0 needs to run as root." >&2
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
13 exit 1
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
14 fi
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
15
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
16 if [ $# -gt 0 ] && [ $1 = stop ]
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
17 then
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
18 socat "EXEC:echo quit" "$CTLSOCKET"
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
19 else
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
20 # Start
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
21 setsid node "$RLGWEBDJS" </dev/null &>>$LOGFILE &
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
22 fi
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
23
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
24 exit
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
25