rlgwebd-stop: avoid the deprecated domain module.
Instead of catching connection errors with domains, install an error listener on the socket before connecting.
This commit is contained in:
parent
2f40fc5387
commit
c4d10ba33d
1 changed files with 7 additions and 10 deletions
11
rlgwebd-stop
11
rlgwebd-stop
|
|
@ -1,22 +1,19 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var net = require('net');
|
var net = require('net');
|
||||||
var domain = require('domain');
|
|
||||||
var sockpath = "/var/run/rlgwebd.sock";
|
var sockpath = "/var/run/rlgwebd.sock";
|
||||||
|
|
||||||
var dom = domain.create();
|
var sock = new net.Socket();
|
||||||
|
|
||||||
dom.on('error', function (err) {
|
sock.on('error', function (err) {
|
||||||
console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped.");
|
console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped.");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
dom.run(function () {
|
sock.connect(sockpath, function () {
|
||||||
var sock = net.connect(sockpath, function () {
|
sock.on('close', function (had_error) {
|
||||||
sock.on('close', function () {
|
|
||||||
if (process.argv[2] == "debug")
|
if (process.argv[2] == "debug")
|
||||||
console.log("Control socket closed");
|
console.log("Control socket closed");
|
||||||
});
|
});
|
||||||
sock.write("quit\n");
|
sock.write("quit\n");
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue