# HG changeset patch # User John "Elwin" Edwards # Date 1461451988 14400 # Node ID a7cc38a0168d66dc72f3e99ba9e073bf1346d816 # Parent 34e1bc4fd6b29d93602e8cb3e52594ffbd97b5a2 Actually restart RLGWebD if it crashes. Also, rlgwebd-stop will no longer crash if RLGWebD has already stopped. diff -r 34e1bc4fd6b2 -r a7cc38a0168d rlgwebd-stop --- a/rlgwebd-stop Mon Feb 01 21:20:12 2016 -0500 +++ b/rlgwebd-stop Sat Apr 23 18:53:08 2016 -0400 @@ -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"); +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"); }); - sock.write("quit\n"); }); diff -r 34e1bc4fd6b2 -r a7cc38a0168d rlgwebd.service --- a/rlgwebd.service Mon Feb 01 21:20:12 2016 -0500 +++ b/rlgwebd.service Sat Apr 23 18:53:08 2016 -0400 @@ -7,6 +7,7 @@ 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