mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
tidy up ping node listeners
This commit is contained in:
parent
41d9f18608
commit
5ba989f09d
@ -42,7 +42,13 @@ module.exports = function(RED) {
|
|||||||
//monitor every spawned process & SIGINT if too long
|
//monitor every spawned process & SIGINT if too long
|
||||||
var spawnTout = setTimeout(() => {
|
var spawnTout = setTimeout(() => {
|
||||||
node.log(`ping - Host '${hostOptions.host}' process timeout - sending SIGINT`)
|
node.log(`ping - Host '${hostOptions.host}' process timeout - sending SIGINT`)
|
||||||
try{if(ex && ex.pid){ ex.kill("SIGINT"); }} catch(e){console.warn(e)}
|
try {
|
||||||
|
if (ex && ex.pid) {
|
||||||
|
ex.removeAllListeners();
|
||||||
|
ex.kill("SIGINT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e) { console.warn(e) }
|
||||||
}, hostOptions.timeout+1000); //add 1s for grace
|
}, hostOptions.timeout+1000); //add 1s for grace
|
||||||
|
|
||||||
var res = false;
|
var res = false;
|
||||||
@ -50,9 +56,11 @@ module.exports = function(RED) {
|
|||||||
var fail = false;
|
var fail = false;
|
||||||
//var regex = /from.*time.(.*)ms/;
|
//var regex = /from.*time.(.*)ms/;
|
||||||
var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9\.]*)/;
|
var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9\.]*)/;
|
||||||
|
if (ex && ex.hasOwnProperty("stdout")) {
|
||||||
ex.stdout.on("data", function (data) {
|
ex.stdout.on("data", function (data) {
|
||||||
line += data.toString();
|
line += data.toString();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
ex.on("exit", function (err) {
|
ex.on("exit", function (err) {
|
||||||
clearTimeout(spawnTout);
|
clearTimeout(spawnTout);
|
||||||
});
|
});
|
||||||
@ -127,8 +135,6 @@ module.exports = function(RED) {
|
|||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
clearPingInterval();
|
clearPingInterval();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("ping",PingNode);
|
RED.nodes.registerType("ping",PingNode);
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-ping",
|
"name" : "node-red-node-ping",
|
||||||
"version" : "0.2.0",
|
"version" : "0.2.1",
|
||||||
"description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.",
|
"description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user