1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-10 05:13:38 +00:00

Hooked up respawn in pseudoservice config to daemon crashRestart

This commit is contained in:
Bryan Roe
2019-10-18 23:54:09 -07:00
parent e23b090ced
commit 001e4944d1
2 changed files with 21 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1303,14 +1303,14 @@ function serviceManager()
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.on('data', function (c) { });
child.stdin.write('cat ' + this.conf + " | tr '\n' '~' | awk -F~ '{ wd=" + '""; parms=""; for(i=1;i<=NF;++i) { split($i, tok1, "="); if(tok1[1]=="workingDirectory") { wd=tok1[2];} if(tok1[1]=="parameters") { parms=tok1[2];} } printf "{ \\\"wd\\\": \\\"%s\\\", \\\"parms\\\": %s }", wd, parms }\'\nexit\n');
child.stdin.write('cat ' + this.conf + " | tr '\n' '~' | awk -F~ '{ wd=" + '""; parms=""; respawn="0"; for(i=1;i<=NF;++i) { split($i, tok1, "="); if(tok1[1]=="workingDirectory") { wd=tok1[2];} if(tok1[1]=="parameters") { parms=tok1[2];} if(tok1[1]=="respawn") { respawn="1"; } } printf "{ \\\"wd\\\": \\\"%s\\\", \\\"parms\\\": %s, \\\"respawn\\\": %s }", wd, parms, respawn }\'\nexit\n');
child.waitExit();
var info = JSON.parse(child.stdout.str.trim());
info.exePath = info.wd + '/' + info.parms.shift();
var options = { pidPath: info.wd + '/pid', logOutputs: false };
require('service-manager').manager.daemon(info.exePath, info.parms , options);
var options = { pidPath: info.wd + '/pid', logOutputs: false, crashRestart: info.respawn ? true : false };
require('service-manager').manager.daemon(info.exePath, info.parms, options);
};
ret.stop = function stop()
{
@@ -1816,7 +1816,10 @@ function serviceManager()
options.parameters.unshift(options.name);
conf.write('parameters=' + JSON.stringify(options.parameters) + '\n');
options.parameters.shift();
if (options.failureRestart == null || options.failureRestart > 0)
{
conf.write('respawn\n');
}
conf.end();
break;
}