mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	@@ -4,7 +4,7 @@ module.exports = function(RED) {
 | 
			
		||||
    var spawn = require("child_process").spawn;
 | 
			
		||||
    var plat = require("os").platform();
 | 
			
		||||
 | 
			
		||||
    function doPing(node, host, arrayMode){
 | 
			
		||||
    function doPing(node, host, arrayMode) {
 | 
			
		||||
        const defTimeout = 5000;
 | 
			
		||||
        var ex, hostOptions, commandLineOptions;
 | 
			
		||||
        if (typeof host === "string") {
 | 
			
		||||
@@ -43,12 +43,9 @@ module.exports = function(RED) {
 | 
			
		||||
        var spawnTout = setTimeout(() => {
 | 
			
		||||
            node.log(`ping - Host '${hostOptions.host}' process timeout - sending SIGINT`)
 | 
			
		||||
            try {
 | 
			
		||||
                if (ex && ex.pid) { 
 | 
			
		||||
                    ex.removeAllListeners();
 | 
			
		||||
                    ex.kill("SIGINT"); 
 | 
			
		||||
                if (ex && ex.pid) { ex.kill("SIGINT"); }
 | 
			
		||||
            }
 | 
			
		||||
            } 
 | 
			
		||||
            catch(e) { console.warn(e) }
 | 
			
		||||
            catch(e) {console.warn(e); }
 | 
			
		||||
        }, hostOptions.timeout+1000); //add 1s for grace
 | 
			
		||||
 | 
			
		||||
        var res = false;
 | 
			
		||||
@@ -56,11 +53,9 @@ module.exports = function(RED) {
 | 
			
		||||
        var fail = false;
 | 
			
		||||
        //var regex = /from.*time.(.*)ms/;
 | 
			
		||||
        var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9\.]*)/;
 | 
			
		||||
        if (ex && ex.hasOwnProperty("stdout")) {
 | 
			
		||||
        ex.stdout.on("data", function (data) {
 | 
			
		||||
            line += data.toString();
 | 
			
		||||
        });
 | 
			
		||||
        }
 | 
			
		||||
        ex.on("exit", function (err) {
 | 
			
		||||
            clearTimeout(spawnTout);
 | 
			
		||||
        });
 | 
			
		||||
@@ -99,7 +94,7 @@ module.exports = function(RED) {
 | 
			
		||||
        function generatePingList(str) {
 | 
			
		||||
            return (str + "").split(",").map((e) => (e + "").trim()).filter((e) => e != "");
 | 
			
		||||
        }
 | 
			
		||||
        function clearPingInterval(){
 | 
			
		||||
        function clearPingInterval() {
 | 
			
		||||
            if (node.tout) { clearInterval(node.tout); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
    "name"          : "node-red-node-ping",
 | 
			
		||||
    "version"       : "0.2.1",
 | 
			
		||||
    "version"       : "0.2.2",
 | 
			
		||||
    "description"   : "A Node-RED node to ping a remote server, for use as a keep-alive check.",
 | 
			
		||||
    "dependencies"  : {
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user