Actually restart RLGWebD if it crashes.

Also, rlgwebd-stop will no longer crash if RLGWebD has already stopped.
This commit is contained in:
John "Elwin" Edwards 2016-04-23 18:53:08 -04:00
parent ba487995e0
commit 2baaad79dd
2 changed files with 17 additions and 6 deletions

View file

@ -1,12 +1,22 @@
#!/usr/bin/env node
var net = require('net');
var domain = require('domain');
var sockpath = "/var/run/rlgwebd.sock";
var sock = net.connect(sockpath, function () {
sock.on('close', function () {
if (process.argv[2] == "debug")
console.log("Control socket closed");
});
sock.write("quit\n");
var dom = domain.create();
dom.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");
});
});

View file

@ -7,6 +7,7 @@ Type=simple
Environment=NODE_PATH=/usr/lib/node_modules
ExecStart=/usr/local/bin/rlgwebd
ExecStop=/usr/local/bin/rlgwebd-stop
Restart=on-failure
[Install]
WantedBy=multi-user.target