Files
pockethost/src/util/exit.ts
2023-11-01 21:27:41 -07:00

12 lines
323 B
TypeScript

import exitHook, { asyncExitHook as _, gracefulExit as __ } from 'exit-hook'
export const asyncExitHook = (cb: () => Promise<void>) => _(cb, { wait: 5000 })
export const gracefulExit = async (signal?: number) => {
__(signal)
await new Promise((resolve) => {
process.on('exit', resolve)
})
}
export { exitHook }