Compare commits
4 Commits
7ff6556d51
...
d14e469ef4
Author | SHA1 | Date | |
---|---|---|---|
d14e469ef4 | |||
99a3e13d77 | |||
b5c895674e | |||
86d2b8c1cf |
20
src/main.js
20
src/main.js
@ -78,13 +78,14 @@ if(errorMsg){
|
||||
logger.debug("Attaching error-logger..");
|
||||
const loggerTcpdump = logFactory("tcpdump");
|
||||
proc.stderr.setEncoding("utf8").on("data", (data) => {
|
||||
if(!data.match(/^(tcpdump: )?listening on /i)) // Catch start-error
|
||||
loggerTcpdump.error(data);
|
||||
if(!data.match(/^(tcpdump: )?listening on /i) || !data.match(/^\d+ packets captured/i)) { // Catch start-error
|
||||
loggerTcpdump.debug(data);
|
||||
}
|
||||
else loggerTcpdump.error(data);
|
||||
});
|
||||
|
||||
regexBlockStream.on('error', (err) => {
|
||||
if(err) loggerTcpdump.error(err);
|
||||
})
|
||||
// FIXME: This is a hacky workaround to not let errors from subprocess bubble up and terminate our process
|
||||
regexBlockStream.on('error', (err) => {});
|
||||
|
||||
proc.on("error", (err) => {
|
||||
loggerTcpdump.error(err);
|
||||
@ -117,5 +118,14 @@ if(errorMsg){
|
||||
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");
|
||||
})();
|
||||
|
Loading…
x
Reference in New Issue
Block a user