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

@relab/graceful-shutdown

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@relab/graceful-shutdown

Graceful shutdown for Node.js application

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
increased by375%
Maintainers
1
Weekly downloads
 
Created
Source

@relab/graceful-shutdown

Tiny and stupid simple dependency-free Node.js library to shut down gracefully.

Requirements

  • Node 18+

Installation

NPM

npm install --save @relab/graceful-shutdown

PNPM

npm add @relab/graceful-shutdown

Usage

import { handleShutdown, onShutdown } from '@relab/graceful-shutdown'

// ...

onShutdown(async () => {
    // clean up your resources here
})

// setup graceful shutdown
handleShutdown()

Custom shutdown timeout

import { handleShutdown, onShutdown } from '@relab/graceful-shutdown'

// ...

// setup graceful shutdown
handleShutdown({
    // 3000ms timeout to complete all shutdown tasks (default - 5000)
    timeout: 3000
})

Shutdown callbacks

import { handleShutdown, onShutdown } from '@relab/graceful-shutdown'

// ...

handleShutdown({
    onShutdownStart: () => {
        console.log('Shut down requested')
    },
    onShutdownError: reason => {
        console.log(`Shutdown tasks error: ${reason}`)
    },
    onShutdownComplete: () => {
        console.log('Shutdown tasks completed')
    },
})

License

Released under MIT by Sergey Zwezdin.

Keywords

FAQs

Package last updated on 17 Jun 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