Mercurial > hg > rlgwebd
annotate rlgwebd-stop @ 202:7f25bb89b59c
Move RLGWebD configuration options into a configuration file.
On startup, rlgwebd now reads /etc/rlgwebd.conf.  If the options for
HTTPS are not found, it will only use HTTP.
| author | John "Elwin" Edwards | 
|---|---|
| date | Wed, 04 Jan 2017 20:28:29 -0500 | 
| parents | a7cc38a0168d | 
| children | ffe22d88bea1 | 
| rev | line source | 
|---|---|
| 193 | 1 #!/usr/bin/env node | 
| 2 | |
| 3 var net = require('net'); | |
| 200 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 4 var domain = require('domain'); | 
| 194 
5483d413a45b
RLGWebD: move the control socket into /var/run.
 John "Elwin" Edwards parents: 
193diff
changeset | 5 var sockpath = "/var/run/rlgwebd.sock"; | 
| 193 | 6 | 
| 200 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 7 var dom = domain.create(); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 8 | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 9 dom.on('error', function (err) { | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 10 console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped."); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 11 process.exit(0); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 12 }); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 13 | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 14 dom.run(function () { | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 15 var sock = net.connect(sockpath, function () { | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 16 sock.on('close', function () { | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 17 if (process.argv[2] == "debug") | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 18 console.log("Control socket closed"); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 19 }); | 
| 
a7cc38a0168d
Actually restart RLGWebD if it crashes.
 John "Elwin" Edwards parents: 
195diff
changeset | 20 sock.write("quit\n"); | 
| 193 | 21 }); | 
| 22 }); | 
