annotate rlgwebd @ 139:dcd07c1d846a

Replace the daemon module with posix. The daemon module doesn't include chroot() anymore, so a replacement is needed. Detaching a daemon keeps getting harder to do in Node, so some setup has been moved into a shell script.
author John "Elwin" Edwards
date Sat, 20 Jul 2013 12:23:53 -0700
parents
children 1a156a7746a7
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
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
3 LOGFILE=/var/local/rlgwebd/log
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
4 CTLSOCKET=/var/local/rlgwebd/ctl
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
5 RLGWEBDJS=./rlgwebd.js
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
6
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
7 if [ $UID != 0 ]
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
8 then
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
9 echo "$0 needs to run as root." >&2
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
10 exit 1
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
11 fi
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
12
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
13 if [ $# -gt 0 ] && [ $1 = stop ]
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
14 then
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
15 socat "EXEC:echo quit" "$CTLSOCKET"
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
16 else
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
17 # Start
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
18 setsid node "$RLGWEBDJS" </dev/null &>>$LOGFILE &
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
19 fi
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
20
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
21 exit
dcd07c1d846a Replace the daemon module with posix.
John "Elwin" Edwards
parents:
diff changeset
22