npm.io
8.0.2 • Published 23h ago

@hypercliq/shutdown-cleanup

Licence
MIT
Version
8.0.2
Deps
0
Size
18 kB
Vulns
0
Weekly
0
Stars
3

@hypercliq/shutdown-cleanup

npm npm downloads CI license

Phased graceful shutdown for Node.js — register async cleanup handlers that run in order when your process receives SIGTERM, SIGINT, SIGHUP, or beforeExit.

Quick start

import { registerHandler } from '@hypercliq/shutdown-cleanup'

registerHandler(async (signal) => {
  await server.close()
  await db.disconnect()
})

Features

  • Phased execution — group handlers into numbered phases, run in order
  • Signal-specific handlers — attach custom logic to one signal without triggering full shutdown
  • Sync and async — both handler types work transparently
  • Error strategiescontinue (default) or stop on handler failure
  • Shutdown timeout — force-exits if cleanup hangs (default 30 s)
  • Custom exit codes
  • TypeScript declarations included
  • ESM-only, Node.js ≥ 22

Installation

npm install @hypercliq/shutdown-cleanup
# or
yarn add @hypercliq/shutdown-cleanup
# or
pnpm add @hypercliq/shutdown-cleanup

Documentation

Full API reference, phased shutdown examples, signal-specific handlers, error strategies, and best practices in the Developer Guide.

License

MIT

Keywords