Mercurial > hg > rlgwebd
annotate rlgwebd-stop @ 213:08665c56c6a0 default tip
Fix race condition related to watching DGL games.
It's possible for a dgamelaunch game to end and cause rlgwebd to stop watching
it before rlgwebd has started watching it.
| author | John "Elwin" Edwards | 
|---|---|
| date | Sun, 16 Aug 2020 20:56:18 -0400 | 
| parents | f06f2d1a5035 | 
| children | 
| rev | line source | 
|---|---|
| 193 | 1 #!/usr/bin/env node | 
| 2 | |
| 3 var net = require('net'); | |
| 208 
f06f2d1a5035
Fix possibly insecure permissions on the control socket.
 John "Elwin" Edwards parents: 
207diff
changeset | 4 var sockpath = "/var/run/rlgwebd/rlgwebd.sock"; | 
| 193 | 5 | 
| 207 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 6 var sock = new net.Socket(); | 
| 200 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 7 | 
| 207 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 8 sock.on('error', function (err) { | 
| 200 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 9 console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped."); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 10 process.exit(0); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 11 }); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 12 | 
| 207 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 13 sock.connect(sockpath, function () { | 
| 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 14 sock.on('close', function (had_error) { | 
| 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 15 if (process.argv[2] == "debug") | 
| 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 16 console.log("Control socket closed"); | 
| 193 | 17 }); | 
| 207 
ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
 John "Elwin" Edwards parents: 
200diff
changeset | 18 sock.write("quit\n"); | 
| 193 | 19 }); | 
