annotate rlgwebd @ 163:0f6da35b27a0

RLGWebD: overhaul the list of current games. The /status WebSocket now only sends a complete list when opened. At 40-second intervals, it sends a list of games that have been updated in the last minute. The client now uses this to keep its own list.
author John "Elwin" Edwards
date Sun, 04 Jan 2015 16:55:57 -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