From 1bf761970f016652424d1aeafd1d2bd42ff21b51 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 29 Nov 2021 13:45:36 +0100 Subject: [PATCH] Added error-handling for regexBlockStream --- src/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 7065a7d..512b8a4 100644 --- a/src/main.js +++ b/src/main.js @@ -61,9 +61,10 @@ if(errorMsg){ let proc = exec(cmd); logger.debug("Creating & Attaching streams.."); + let regexBlockStream = new RegexBlockStream(/^\d{2}:\d{2}:\d{2}.\d{6}.*(\n( {4,8}|\t\t?).*)+\n/gm); proc.stdout .setEncoding("utf8") - .pipe(new RegexBlockStream(/^\d{2}:\d{2}:\d{2}.\d{6}.*(\n( {4,8}|\t\t?).*)+\n/gm)) + .pipe(regexBlockStream) .pipe(new PacketStreamFactory()) .pipe(new PacketInfluxPointFactory()) .pipe(new InfluxPointWriter(influxDb, env.INFLUX_ORG, env.INFLUX_BUCKET)); @@ -75,6 +76,10 @@ if(errorMsg){ loggerTcpdump.error(data); }); + regexBlockStream.on('error', (err) => { + if(err) loggerTcpdump.error(err); + }) + proc.on("error", (err) => { loggerTcpdump.error(err); });