Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-graceful-shutdown

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-graceful-shutdown

Gracefully shutdown fastify

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by5.79%
Maintainers
0
Weekly downloads
 
Created
Source

🏹 fastify-graceful-shutdown

styled with prettier NPM version

Shutdown Fastify graceful asynchronously. By default the fastify close hook is called when SIGINT or SIGTERM was triggered.

Features

  • Graceful and debug friendly shutdown
  • Flush the fastify logger before process exit to avoid losing logs
  • Handlers are called in parallel for faster shutdown

Install

npm install --save fastify-graceful-shutdown

Register plugin

fastify.register(require('fastify-graceful-shutdown'))

Usage

fastify.after(() => {
  fastify.gracefulShutdown((signal, next) => {
    fastify.log.info('Received signal to shutdown: %s', signal)
    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.

Keywords

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc