From d1a2cd2b3c68aabdabc51a383ea46606b0007d64 Mon Sep 17 00:00:00 2001 From: Nikita Savchenko Date: Sun, 10 Apr 2022 14:47:32 +0530 Subject: [PATCH] Remove Travis, update files --- .npmignore | 6 ------ .travis.yml | 4 ---- package.json | 6 +++++- readme.md | 39 +++++++++++++++++++++------------------ 4 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 .npmignore delete mode 100644 .travis.yml diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 99bef88..0000000 --- a/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -* -!index.js -!LICENSE -!readme.md -!package.json -!index.d.ts \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f7de5cf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - '8' - - '10' \ No newline at end of file diff --git a/package.json b/package.json index d5feb0d..041aa82 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,12 @@ { "name": "node-graceful-shutdown", - "version": "1.1.1", + "version": "1.1.2", "description": "Gracefully shutdown your modular NodeJS application", "main": "index.js", + "files": [ + "index.js", + "index.d.ts" + ], "engines": { "node": ">=6" }, diff --git a/readme.md b/readme.md index deca735..3e5b6d1 100644 --- a/readme.md +++ b/readme.md @@ -2,14 +2,13 @@ [![npm](https://img.shields.io/npm/v/node-graceful-shutdown.svg)](https://www.npmjs.com/package/node-graceful-shutdown) [![License](https://img.shields.io/github/license/zitros/node-graceful-shutdown.svg)](LICENSE) -[![Build Status](https://travis-ci.org/ZitRos/node-graceful-shutdown.svg?branch=master)](https://travis-ci.org/ZitRos/node-graceful-shutdown) +[![Build Status](https://img.shields.io/github/workflow/status/zitros/node-graceful-shutdown/Node.js%20package)](https://github.com/ZitRos/node-graceful-shutdown/actions/workflows/build-and-push.yaml) Gracefully handle your modular NodeJS application's shutdown (termination), using dependencies. Process signals captured: `SIGINT`, `SIGTERM`, `SIGQUIT`. -Example -------- +## Example It doesn't matter in which order and where you define these graceful handlers, `node-graceful-shutdown` will handle them appropriately and exit the process once all of them are processed. @@ -19,17 +18,17 @@ import { onShutdown } from "node-graceful-shutdown"; // module1.js onShutdown("http-server", async function () { - // Stop your http server here. + // Stop your http server here. }); // module2.js onShutdown("message-bus", ["http-server"], async function () { - // Close your RabbitMQ connection here ONLY AFTER http server's onShutdown completed. + // Close your RabbitMQ connection here ONLY AFTER http server's onShutdown completed. }); // moduleX.js onShutdown("database", ["http-server", "message-bus"], async function () { - // Shut down your database here, ONLY AFTER http-server and message-bus are completed. + // Shut down your database here, ONLY AFTER http-server and message-bus are completed. }); // After all handlers are processed without errors, process exits with code 0. @@ -44,31 +43,36 @@ this will work at its best in your application's `main.js`: ```javascript import { onShutdown } from "node-graceful-shutdown"; -import { startModule1, startModule2, stopModule1, stopModule2 /*, ...*/ } from "./src"; +import { + startModule1, + startModule2, + stopModule1, + stopModule2 /*, ...*/, +} from "./src"; export const startMyApp = async () => { - await startModule1(); - await startModule2(); + await startModule1(); + await startModule2(); }; export const stopMyApp = async () => { - // Stop modules one after another. - await stopModule1(); - await stopModule2(); - // ... + // Stop modules one after another. + await stopModule1(); + await stopModule2(); + // ... }; // Handle application's shutdown. onShutdown(stopMyApp); ``` -Features and Guidelines ------------------------ +## Features and Guidelines This library, along existing ones, allow your application to be **modular**. You define a cleanup callback in-place, -in the same module, where initialization happens. In addition, it allows specifying the order +in the same module, where initialization happens. In addition, it allows specifying the order Recommendations: + 1. Please, **do not use this module in libraries** (packages). It is intended for end applications only (see why in `5.`). 2. Once imported, `onShutdown` is application-wide (in terms of a single process), so the callbacks and their dependencies will see each other when imported from multiple files. 3. Circular shutdown handler dependencies will throw an error immediately once declared. @@ -76,7 +80,6 @@ Recommendations: 5. Importing this module **deletes** existing handlers (`SIGINT`, `SIGTERM`, `SIGQUIT`) if there are any. This is intended as other custom handlers can exit the process at any time. 6. You may also consider defining constants in your application, instead of string arguments (names). -Licence -------- +## Licence [MIT](LICENSE) © [Nikita Savchenko](https://nikita.tk/developer)