Mercurial > hg > rlgwebd
changeset 207:ffe22d88bea1
rlgwebd-stop: avoid the deprecated domain module.
Instead of catching connection errors with domains, install an error
listener on the socket before connecting.
author | John "Elwin" Edwards |
---|---|
date | Fri, 27 Jan 2017 19:18:31 -0500 |
parents | 04c2a895b679 |
children | f06f2d1a5035 |
files | rlgwebd-stop |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/rlgwebd-stop Fri Jan 27 15:43:10 2017 -0500 +++ b/rlgwebd-stop Fri Jan 27 19:18:31 2017 -0500 @@ -1,22 +1,19 @@ #!/usr/bin/env node var net = require('net'); -var domain = require('domain'); 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."); process.exit(0); }); -dom.run(function () { - var sock = net.connect(sockpath, function () { - sock.on('close', function () { - if (process.argv[2] == "debug") - console.log("Control socket closed"); - }); - sock.write("quit\n"); +sock.connect(sockpath, function () { + sock.on('close', function (had_error) { + if (process.argv[2] == "debug") + console.log("Control socket closed"); }); + sock.write("quit\n"); });