Documentation / @andrew_l/graceful / onShutdown
Function: onShutdown()
onShutdown(handler)
onShutdown(
handler
):CancelCallback
Gracefully terminate application's modules on shutdown.
Parameters
• handler: Handler
<unknown
>
Async or sync function which handles shutdown.
Returns
CancelCallback
onShutdown(name, handler)
onShutdown(
name
,handler
):CancelCallback
Gracefully terminate application's modules on shutdown.
Parameters
• name: string
Name of the handler.
• handler: Handler
<unknown
>
Async or sync function which handles shutdown.
Returns
CancelCallback
onShutdown(dependencies, handler)
onShutdown(
dependencies
,handler
):CancelCallback
Gracefully terminate application's modules on shutdown.
Parameters
• dependencies: string
[]
Which handlers should be processed first.
• handler: Handler
<unknown
>
Async or sync function which handles shutdown.
Returns
CancelCallback
onShutdown(name, dependencies, handler)
onShutdown(
name
,dependencies
,handler
):CancelCallback
Gracefully terminate application's modules on shutdown.
Parameters
• name: string
Name of the handler.
• dependencies: string
[]
Which handlers should be processed first.
• handler: Handler
<unknown
>
Async or sync function which handles shutdown.
Returns
CancelCallback
Example
// This will called after http server close
onShutdown('mongoose', ['http-server'], async () => {
console.info('Graceful: mongodb connection.');
await mongoose.disconnect();
});
onShutdown('http-server', async () => {
console.info('Graceful: http server.');
await httpServer.close();
});