Comparing version 0.1.1 to 0.1.2
@@ -0,1 +1,8 @@ | ||
## [0.1.2](https://github.com/ayZagen/pino-kafka/compare/v0.1.1...v0.1.2) (2021-04-10) | ||
### Features | ||
* **cli:** flush kafka queue on process exit ([5793b40](https://github.com/ayZagen/pino-kafka/commit/5793b40c750aa701e76a3ca52a746ff89a4860a5)) | ||
## [0.1.1](https://github.com/ayZagen/pino-kafka/compare/v0.1.0...v0.1.1) (2021-04-10) | ||
@@ -2,0 +9,0 @@ |
32
cli.js
@@ -9,2 +9,3 @@ #! /usr/bin/env node | ||
const pinoKafka = require('./pkafka') | ||
const util = require("util"); | ||
@@ -55,5 +56,34 @@ function keysToDotNotation(obj, current, final) { | ||
} | ||
const stream = pinoKafka(opts) | ||
pump(process.stdin, stream) | ||
pump(process.stdin, pinoKafka(opts)) | ||
function terminator( sig ) { | ||
if ( typeof sig === 'string' ) { | ||
flushKafkaQueue(function (err) { | ||
process.exit(err ? 1 : 0); | ||
}); | ||
} | ||
} | ||
async function flushKafkaQueue( callback ){ | ||
stream._kafka.flush(opts.timeout, err => { | ||
if(err){ | ||
process.stderr.write(util.format.apply(this, err) + '\n') | ||
} | ||
callback(err) | ||
}) | ||
} | ||
['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', | ||
'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM' | ||
].forEach(function (sig) { | ||
process.on(sig, function () { | ||
try { | ||
terminator(sig); | ||
} catch (e) { | ||
process.exit(1) | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -60,0 +90,0 @@ |
{ | ||
"name": "pino-kafka", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A pino 'transport' for writing to kafka", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ayZagen/pino-kafka", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46694
169