diff --git a/utility/daemon/daemon.js b/utility/daemon/daemon.js index 928f8143..d3ab3817 100644 --- a/utility/daemon/daemon.js +++ b/utility/daemon/daemon.js @@ -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")); } diff --git a/utility/daemon/locales/en-US/daemon.json b/utility/daemon/locales/en-US/daemon.json index 20263c3b..52ef4091 100644 --- a/utility/daemon/locales/en-US/daemon.json +++ b/utility/daemon/locales/en-US/daemon.json @@ -37,7 +37,8 @@ "notrunning": "Command not running", "notfound": "Command not found", "notexecutable": "Command not executable", - "restarting": "Restarting" + "restarting": "Restarting", + "pipeclosed": "Process closed" } } } \ No newline at end of file diff --git a/utility/daemon/package.json b/utility/daemon/package.json index 1d353087..f6b7272b 100644 --- a/utility/daemon/package.json +++ b/utility/daemon/package.json @@ -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" : { },