chore: improve process exit cleanup

This commit is contained in:
Ben Allfree
2023-10-21 03:20:37 -07:00
parent db2a47fd4a
commit 39a45b0aec

View File

@@ -1,5 +1,6 @@
import { PUBLIC_DEBUG } from '$constants'
import { LoggerService } from '@pockethost/common'
import { gracefulExit } from 'exit-hook'
;['unhandledRejection', 'uncaughtException'].forEach((type) => {
process.on(type, (e) => {
const { error } = LoggerService().create(type)
@@ -7,7 +8,8 @@ import { LoggerService } from '@pockethost/common'
error(`${e}`)
if (PUBLIC_DEBUG) {
throw e
console.error(e.stack)
gracefulExit()
}
})
})