Mercurial > hg > rlgwebd
comparison rlgwebd-stop @ 200:a7cc38a0168d
Actually restart RLGWebD if it crashes.
Also, rlgwebd-stop will no longer crash if RLGWebD has already stopped.
author | John "Elwin" Edwards |
---|---|
date | Sat, 23 Apr 2016 18:53:08 -0400 |
parents | 3bdee6371c3f |
children | ffe22d88bea1 |
comparison
equal
deleted
inserted
replaced
199:34e1bc4fd6b2 | 200:a7cc38a0168d |
---|---|
1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
2 | 2 |
3 var net = require('net'); | 3 var net = require('net'); |
4 var domain = require('domain'); | |
4 var sockpath = "/var/run/rlgwebd.sock"; | 5 var sockpath = "/var/run/rlgwebd.sock"; |
5 | 6 |
6 var sock = net.connect(sockpath, function () { | 7 var dom = domain.create(); |
7 sock.on('close', function () { | 8 |
8 if (process.argv[2] == "debug") | 9 dom.on('error', function (err) { |
9 console.log("Control socket closed"); | 10 console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped."); |
11 process.exit(0); | |
12 }); | |
13 | |
14 dom.run(function () { | |
15 var sock = net.connect(sockpath, function () { | |
16 sock.on('close', function () { | |
17 if (process.argv[2] == "debug") | |
18 console.log("Control socket closed"); | |
19 }); | |
20 sock.write("quit\n"); | |
10 }); | 21 }); |
11 sock.write("quit\n"); | |
12 }); | 22 }); |