fix: instance logger tails cleaned up on exit

This commit is contained in:
Ben Allfree 2024-01-15 08:47:51 -08:00
parent 80b3da319a
commit 0799d1e11b

View File

@ -1,5 +1,6 @@
import { DEBUG, mkInstanceDataPath } from '$constants' import { DEBUG, mkInstanceDataPath } from '$constants'
import { LoggerService, createCleanupManager } from '$shared' import { LoggerService, createCleanupManager } from '$shared'
import { asyncExitHook } from '$util'
import * as fs from 'fs' import * as fs from 'fs'
import { Tail } from 'tail' import { Tail } from 'tail'
import * as winston from 'winston' import * as winston from 'winston'
@ -103,8 +104,11 @@ export function InstanceLogger(instanceId: string, target: string) {
} }
check() check()
const unsub = asyncExitHook(() => cm.shutdown())
return () => { return () => {
cm.shutdown() cm.shutdown()
unsub()
} }
}, },
} }