Compare commits
No commits in common. "d14e469ef4121e92dc8b0a16e902ecacfeb17fcc" and "7ff6556d510ba03357ef2991c9fef426c1b1cda7" have entirely different histories.
d14e469ef4
...
7ff6556d51
20
src/main.js
20
src/main.js
@ -78,14 +78,13 @@ if(errorMsg){
|
|||||||
logger.debug("Attaching error-logger..");
|
logger.debug("Attaching error-logger..");
|
||||||
const loggerTcpdump = logFactory("tcpdump");
|
const loggerTcpdump = logFactory("tcpdump");
|
||||||
proc.stderr.setEncoding("utf8").on("data", (data) => {
|
proc.stderr.setEncoding("utf8").on("data", (data) => {
|
||||||
if(!data.match(/^(tcpdump: )?listening on /i) || !data.match(/^\d+ packets captured/i)) { // Catch start-error
|
if(!data.match(/^(tcpdump: )?listening on /i)) // Catch start-error
|
||||||
loggerTcpdump.debug(data);
|
loggerTcpdump.error(data);
|
||||||
}
|
|
||||||
else loggerTcpdump.error(data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: This is a hacky workaround to not let errors from subprocess bubble up and terminate our process
|
regexBlockStream.on('error', (err) => {
|
||||||
regexBlockStream.on('error', (err) => {});
|
if(err) loggerTcpdump.error(err);
|
||||||
|
})
|
||||||
|
|
||||||
proc.on("error", (err) => {
|
proc.on("error", (err) => {
|
||||||
loggerTcpdump.error(err);
|
loggerTcpdump.error(err);
|
||||||
@ -118,14 +117,5 @@ if(errorMsg){
|
|||||||
exit(0);
|
exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle stop-signals for graceful shutdown
|
|
||||||
function shutdownReq() {
|
|
||||||
logger.info("Shutdown request received..");
|
|
||||||
logger.debug("Stopping subprocess tcpdump, then exiting myself..");
|
|
||||||
proc.kill(); // Kill process (send SIGTERM), then upper event-handler will stop self
|
|
||||||
}
|
|
||||||
process.on('SIGTERM', shutdownReq);
|
|
||||||
process.on('SIGINT', shutdownReq);
|
|
||||||
|
|
||||||
logger.info("Startup complete");
|
logger.info("Startup complete");
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user