-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to close/flush/end ? #2
Comments
Same problem, in my express program I manually restart serve will prompt me the port is occupied, after troubleshooting is due to the pino-rotating-file plugin is not properly closed, in the project compressed into a zip will also be prompted the log file is being used! |
I found the problem, the reason is that SIGINT “does not emit the ‘exit’ event and pino transport cannot call the close method correctly. |
Thanks for the feedback, I used the close-with-grace package to perform the stream closure. import closeWithGrace from 'close-with-grace'
import build from 'pino-abstract-transport'
import { RotateFileStream, type RotateFileTransportOptions } from './RotateFileStream'
export default (opts: RotateFileTransportOptions) => {
const destination = new RotateFileStream(opts)
closeWithGrace(() => {
destination.end()
})
return build(
source => {
source.pipe(destination)
},
{
close(err, cb) {
destination.on('close', cb.bind(null, err))
destination.end()
},
parse: 'lines',
parseLine: line => line
}
)
} |
Was just testing this briefly and I notice that the scripts does not automatically close on completion, meaning there's probably some event handler or something that is left hanging, which is different from when using 'pino/file' where it terminates properly.
Is there some close() or end() or something method that needs to be called to make it terminate?
The text was updated successfully, but these errors were encountered: