Actually restart RLGWebD if it crashes.
Also, rlgwebd-stop will no longer crash if RLGWebD has already stopped.
This commit is contained in:
parent
ba487995e0
commit
2baaad79dd
2 changed files with 17 additions and 6 deletions
22
rlgwebd-stop
22
rlgwebd-stop
|
|
@ -1,12 +1,22 @@
|
||||||
#!/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 sock = net.connect(sockpath, function () {
|
var dom = domain.create();
|
||||||
sock.on('close', function () {
|
|
||||||
if (process.argv[2] == "debug")
|
dom.on('error', function (err) {
|
||||||
console.log("Control socket closed");
|
console.log("Cannot connect to " + sockpath + ", rlgwebd already stopped.");
|
||||||
});
|
process.exit(0);
|
||||||
sock.write("quit\n");
|
});
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ Type=simple
|
||||||
Environment=NODE_PATH=/usr/lib/node_modules
|
Environment=NODE_PATH=/usr/lib/node_modules
|
||||||
ExecStart=/usr/local/bin/rlgwebd
|
ExecStart=/usr/local/bin/rlgwebd
|
||||||
ExecStop=/usr/local/bin/rlgwebd-stop
|
ExecStop=/usr/local/bin/rlgwebd-stop
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue