Add specific daemons node stdin error handler

to address issue #960
This commit is contained in:
Dave Conway-Jones 2022-11-16 12:02:30 +00:00
parent c3a5716fe7
commit 074ca44b5f
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 11 additions and 4 deletions

View File

@ -50,9 +50,9 @@ module.exports = function(RED) {
if (node.cr === true) { msg.payload += "\n"; }
}
node.debug("inp: "+msg.payload);
lastmsg = msg;
if (node.child !== null && node.running) { node.child.stdin.write(msg.payload); }
else { node.warn(RED._("daemon.errors.notrunning")); }
lastmsg = msg;
}
}
}
@ -65,7 +65,7 @@ module.exports = function(RED) {
}
let args = node.args;
if (appendArgs !== undefined && appendArgs.length > 0) {
args = args.concat(appendArgs);
args = args.concat(appendArgs);
}
try {
@ -120,6 +120,12 @@ module.exports = function(RED) {
else { node.log('error: ' + err); }
node.status({fill:"red",shape:"ring",text:RED._("daemon.status.error")});
});
node.child.stdin.on('error', function (err) {
if (err.errno === "EPIPE") { node.error(RED._("daemon.errors.pipeclosed"),lastmsg); }
else { node.log('error: ' + err); }
node.status({fill:"red",shape:"ring",text:RED._("daemon.status.error")});
});
}
catch(e) {
if (e.errno === "ENOENT") { node.warn(RED._("daemon.errors.notfound")); }

View File

@ -37,7 +37,8 @@
"notrunning": "Command not running",
"notfound": "Command not found",
"notexecutable": "Command not executable",
"restarting": "Restarting"
"restarting": "Restarting",
"pipeclosed": "Process closed"
}
}
}

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-daemon",
"version" : "0.5.0",
"version" : "0.5.1",
"description" : "A Node-RED node that runs and monitors a long running system command.",
"dependencies" : {
},