Mercurial > hg > rlgwebd
view rlgwebd-stop @ 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 | a7cc38a0168d |
children | f06f2d1a5035 |
line wrap: on
line source
#!/usr/bin/env node var net = require('net'); var sockpath = "/var/run/rlgwebd.sock"; var sock = new net.Socket(); sock.on('error', function (err) { console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped."); process.exit(0); }); sock.connect(sockpath, function () { sock.on('close', function (had_error) { if (process.argv[2] == "debug") console.log("Control socket closed"); }); sock.write("quit\n"); });