correctly pass error on failure to launch

This commit is contained in:
AJ ONeal 2018-06-28 00:44:41 -06:00
parent ca933704e1
commit b1b5e32525
1 changed files with 4 additions and 4 deletions

View File

@ -72,7 +72,6 @@ Launcher.install = function (things, fn) {
var stdout = fs.openSync(path.join(logpath, 'info.log'), 'a');
var stderr = fs.openSync(path.join(logpath, 'error.log'), 'a');
var killed = 0;
var err;
var subprocess = spawn(
vars.telebitNode
@ -88,15 +87,16 @@ Launcher.install = function (things, fn) {
subprocess.unref();
subprocess.on('error', function (_err) {
err = _err;
killed += 1;
});
subprocess.on('exit', function (code, signal) {
if (!err) { err = new Error('' + code + ' ' + signal + ' failure to launch'); }
killed += 1;
});
setTimeout(function () {
if (fn) { fn(null); return; }
if (fn) {
fn(err);
return;
}
}, 1 * 1000);
return;
}