Mercurial > hg > rlgwebd
comparison rlgwebd.js @ 85:4303d94d87a2
rlgwebd.js: Unlink control socket at startup.
Unlinking at shutdown doesn't work because at that time, the process is
chroot'ed and unprivileged.
| author | John "Elwin" Edwards <elwin@sdf.org> |
|---|---|
| date | Sun, 08 Jul 2012 17:49:43 -0700 |
| parents | d59dc5cef412 |
| children | bd2cf6dda28d |
comparison
equal
deleted
inserted
replaced
| 84:d59dc5cef412 | 85:4303d94d87a2 |
|---|---|
| 990 | 990 |
| 991 function shutdown () { | 991 function shutdown () { |
| 992 httpServer.close(); | 992 httpServer.close(); |
| 993 httpServer.removeAllListeners('request'); | 993 httpServer.removeAllListeners('request'); |
| 994 ctlServer.close(); | 994 ctlServer.close(); |
| 995 fs.unlink(ctlsocket); | |
| 996 tslog("Shutting down..."); | 995 tslog("Shutting down..."); |
| 997 process.exit(); | 996 process.exit(); |
| 998 } | 997 } |
| 999 | 998 |
| 1000 function conHandler(chunk) { | 999 function conHandler(chunk) { |
| 1024 tslog("Not running as root, cannot chroot."); | 1023 tslog("Not running as root, cannot chroot."); |
| 1025 process.exit(1); | 1024 process.exit(1); |
| 1026 } | 1025 } |
| 1027 | 1026 |
| 1028 var httpServer; // declare here so shutdown() can find it | 1027 var httpServer; // declare here so shutdown() can find it |
| 1028 | |
| 1029 /* This could be nonblocking, but nothing else can start yet anyway. */ | |
| 1030 if (fs.existsSync(ctlsocket)) { | |
| 1031 fs.unlinkSync(ctlsocket); | |
| 1032 } | |
| 1029 | 1033 |
| 1030 /* Open the control socket before chrooting where it can't be found */ | 1034 /* Open the control socket before chrooting where it can't be found */ |
| 1031 var ctlServer = net.createServer(function (sock) { | 1035 var ctlServer = net.createServer(function (sock) { |
| 1032 sock.on('data', conHandler); | 1036 sock.on('data', conHandler); |
| 1033 }); | 1037 }); |
