From 8211f55b89a847832376711209f51fcf07d10ade Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 29 Nov 2021 15:10:42 +0100 Subject: [PATCH] Added check for tcpdump-process stdout --- src/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.js b/src/main.js index 12f2f69..bfd719d 100644 --- a/src/main.js +++ b/src/main.js @@ -14,6 +14,9 @@ const { PacketStreamFactory } = require("./streamHandler/PacketStreamFactory.js" const { PacketInfluxPointFactory } = require("./streamHandler/PacketInfluxPointFactory.js"); const { InfluxPointWriter } = require("./streamHandler/InfluxPointWriter.js"); +const userHelper = require("./helper/userHelper.js"); + + /// Setup ENVs const env = process.env; // Defaults @@ -87,6 +90,14 @@ if(errorMsg){ loggerTcpdump.error(err); }); + userHelper.detectStreamData(proc.stdout, 10000) // Expect tcpdump-logs to have data after max. 10s + .then(() => { + loggerTcpdump.debug("Got first data"); + }) + .catch((err) => { + if(err == 'timeout') loggerTcpdump.warn("No data after 10s! Wrong configuration?"); + }); + logger.debug("Attaching exit-handler.."); proc.on("exit", (code) => { loggerTcpdump.debug(`tcpdump exited code: ${code}`);