# HG changeset patch # User John "Elwin" Edwards # Date 1485562711 18000 # Node ID ffe22d88bea1d819af7d326eb5e1eb5989bcef15 # Parent 04c2a895b6791f02e742c18bcedb8f7a2fca5eb3 rlgwebd-stop: avoid the deprecated domain module. Instead of catching connection errors with domains, install an error listener on the socket before connecting. diff -r 04c2a895b679 -r ffe22d88bea1 rlgwebd-stop --- 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"); });