Fix hanging "Clear All Data" on Windows

This commit is contained in:
Fedor Indutny 2021-05-13 13:54:54 -07:00 committed by Scott Nonnenberg
parent 03eaa9eb3e
commit fe505a7f2f
8 changed files with 58 additions and 14 deletions

View file

@ -101,6 +101,11 @@ function fetch(): Promise<string> {
}
let globalLogger: undefined | pino.Logger;
let shouldRestart = false;
export function beforeRestart(): void {
shouldRestart = true;
}
export function initialize(): void {
if (globalLogger) {
@ -114,13 +119,16 @@ export function initialize(): void {
rotate: 3,
});
stream.on('close', () => {
const onClose = () => {
globalLogger = undefined;
});
stream.on('error', () => {
globalLogger = undefined;
});
if (shouldRestart) {
initialize();
}
};
stream.on('close', onClose);
stream.on('error', onClose);
globalLogger = pino(
{