All Projects → simonecorsi → fine

simonecorsi / fine

Licence: MIT license
🧹 Gracefully shutdown Node.js application: help you handle exit signals and cleanup

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to fine

graceful
Gracefully exit server (Koa), database (Mongo/Mongoose), Redis clients, and job scheduler (Redis/Bull)
Stars: ✭ 37 (+85%)
Mutual labels:  handler, process, exit, graceful
Human Signals
Human-friendly process signals
Stars: ✭ 223 (+1015%)
Mutual labels:  process, signal
ProcessInjector.NET
Learning Process Injection and Hollowing techniques
Stars: ✭ 23 (+15%)
Mutual labels:  hook, process
HiFramework.Unity
Based on component to manage project's core logic and module used in unity3d
Stars: ✭ 22 (+10%)
Mutual labels:  event, signal
Eventpp
Minimal C++ Event Bus
Stars: ✭ 69 (+245%)
Mutual labels:  event, signal
Log Process Errors
Show some ❤️ to Node.js process errors
Stars: ✭ 424 (+2020%)
Mutual labels:  handler, process
purescript-wire
Events and Signals for FRP. Monad instances included
Stars: ✭ 13 (-35%)
Mutual labels:  event, signal
libmem
Advanced Game Hacking Library for C/C++, Rust and Python (Windows/Linux/FreeBSD) (Process/Memory Hacking) (Hooking/Detouring) (Cross Platform) (x86/x64/ARM/ARM64) (DLL/SO Injection) (Internal/External)
Stars: ✭ 336 (+1580%)
Mutual labels:  hook, process
node-graceful-shutdown
Gracefully shutdown your modular NodeJS application.
Stars: ✭ 20 (+0%)
Mutual labels:  shutdown, graceful
antropy
AntroPy: entropy and complexity of (EEG) time-series in Python
Stars: ✭ 111 (+455%)
Mutual labels:  signal
use-react-router-breadcrumbs
tiny, flexible, hook for rendering route breadcrumbs with react-router v6
Stars: ✭ 170 (+750%)
Mutual labels:  hook
GCommands
Powerful and flexible discord.js framework.
Stars: ✭ 38 (+90%)
Mutual labels:  handler
use-scroll-direction
A simple, performant, and cross-browser hook for detecting scroll direction in your next react app.
Stars: ✭ 24 (+20%)
Mutual labels:  hook
chef-handler-sns
Chef report handler to send Amazon SNS notifications on failures or changes.
Stars: ✭ 12 (-40%)
Mutual labels:  handler
signal-portable
🚀 Signal portable for Windows
Stars: ✭ 22 (+10%)
Mutual labels:  signal
covidbot
Multi-platform messenger bot which provides updates on current COVID19 situation for Germany
Stars: ✭ 51 (+155%)
Mutual labels:  signal
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+440%)
Mutual labels:  event
PtraceInject
Android进程注入学习笔记
Stars: ✭ 70 (+250%)
Mutual labels:  hook
busy
Busy is a mouse movement simulator. It stops your system from going to sleep / idling and makes sure that you keep getting those notifications while you take that well deserved break.
Stars: ✭ 15 (-25%)
Mutual labels:  shutdown
akeneo-events-api-bundle
The Events API Bundle for Akeneo PIM delivers catalog changes as events to a 3rd party systems.
Stars: ✭ 18 (-10%)
Mutual labels:  event

fine

"Fine" means "End" in Italian, [fì-ne] Cessazione definitiva, punto estremo, nello spazio e nel tempo di qualcosa.

About

Zero dependency and opinionated package that gracefully shutdown Node.js applications.

It provides extendability by taking an array of callbacks that will be executed serially to allow closing user-defined resources, eg: a database connection, drain streams, etc; before timeout exits the main process.

ESM

This package now exports both ESM and CommonJS. If, for some reason, you really really need only the CommonJS version refer to v1.4.0.

Table of contents

Installation

You can install locally

npm i @scdev/fine

Usage

// Example
const http = require("http");
const { promisify } = require("util");
const fine = require("@scdev/fine");

const server = http.createServer(/* your handler */);

fine(
  [
    // Tip: you can wait that all connection are closed
    promisify(server.close),
    // or you can just sto accepting new one and continue closing other callbacks
    server.close,

    async () => {
      // Throws will be NOOP-ed
      await db.disconnect();
    },
  ],
  {
    timeout: 2000,
    events: ["SIGINT", "SIGTERM", "uncaughtException", "unhandledRejection"],
  }
);

// ...

Arguments

fine(callbacks, options);
parameter type description default
callbacks function[] Collection of callback for custom closing events, eg: db.disconnect() []
options.timeout Number The time before exiting the process 2000
options.events string[] The events the process will listen on ["SIGINT", "SIGTERM", "uncaughtException", "unhandledRejection"]
options.unref boolean Should the timeout keep the process alive or not false

Contributing

Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome!

This projects uses commitlint with Angular configuration so be sure to use standard commit format or PR won't be accepted

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'feat(scope): some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Simone Corsi - @im_simonecorsi

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].