Package Exports
- fastify-graceful-shutdown
- fastify-graceful-shutdown/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fastify-graceful-shutdown) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🏹 fastify-graceful-shutdown
Note: If you are looking for a simple generic module to run shutdown logic, I recommend using close-with-grace.
fastify-graceful-shutdown
goes an opinionated way, and does want to solve all use cases.
Shutdown Fastify graceful asynchronously. By default the fastify close
hook is called when SIGINT
or SIGTERM
was triggered.
Install
npm install --save fastify-graceful-shutdown
Register plugin
fastify.register(require('fastify-graceful-shutdown'))
Usage
fastify.after(() => {
fastify.gracefulShutdown((signal, next) => {
console.log('Upps!')
next()
})
})
Compatibility
Fastify >=3
Caveats
- Don't register signal handlers otherwise except with this plugin.
- Can't be used with a different logger other than Pino because we use the child logger feature to encapsulate the logs.
- Use fastify
onClose
hook to release resources in your plugin. - The process will be exited after a certain timeout (Default 10 seconds) to protect against stuck process.