@relab/graceful-shutdown
Tiny and stupid simple dependency-free Node.js library to shut down gracefully.
Requirements
Installation
NPM
npm install --save @relab/graceful-shutdown
PNPM
npm add @relab/graceful-shutdown
Usage
import { handleShutdown, onShutdown } from '@relab/graceful-shutdown'
onShutdown(async () => {
})
handleShutdown()
Custom shutdown timeout
import { handleShutdown, onShutdown } from '@relab/graceful-shutdown'
handleShutdown({
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.