This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ec7201
commit e91e52d
Showing
14 changed files
with
7,474 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
release: | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
id-token: write | ||
name: Release | ||
runs-on: ubuntu-latest | ||
environment: npm | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "PNPM_CACHE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.PNPM_CACHE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- run: pnpm install | ||
|
||
- run: npx semantic-release | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
TELEGRAM_BOT_CHAT_ID: ${{ vars.TELEGRAM_BOT_CHAT_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
use-node-version=20.14.0 | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const common = require('@relab/semantic-release-commits-config') | ||
|
||
module.exports = { | ||
...common, | ||
plugins: [ | ||
...common.plugins, | ||
'@semantic-release/pnpm', | ||
[ | ||
'@semantic-release/git', | ||
{ | ||
assets: ['package.json'], | ||
message: 'Update package.json version to ${nextRelease.version}', | ||
}, | ||
], | ||
'@semantic-release/github', | ||
[ | ||
'semantic-release-telegram-bot', | ||
{ | ||
notifications: [ | ||
{ | ||
chatIds: process.env.TELEGRAM_BOT_CHAT_ID, | ||
}, | ||
], | ||
}, | ||
], | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,74 @@ | ||
# node-graceful-shutdown | ||
Graceful shutdown for Node.js application | ||
<h1 align="center">🚀 Graceful Shutdown for Node.js</h1> | ||
|
||
<p align="center">Tiny and stupid simple dependency-free Node.js library to shutdown gracefully.</p> | ||
|
||
## Requirements | ||
|
||
- Node 18+ | ||
|
||
## Installation | ||
|
||
### NPM | ||
|
||
``` | ||
npm install --save @relab/graceful-shutdown | ||
``` | ||
|
||
### PNPM | ||
|
||
``` | ||
npm add @relab/graceful-shutdown | ||
``` | ||
|
||
## Usage | ||
|
||
```Typescript | ||
import { handleShutdown, onShutdown } from './utils/@shutdown' | ||
|
||
// ... | ||
|
||
onShutdown(async () => { | ||
// clean up your resources here | ||
}) | ||
|
||
// setup graceful shutdown | ||
handleShutdown() | ||
``` | ||
|
||
### Custom shutdown timeout | ||
|
||
```Typescript | ||
import { handleShutdown, onShutdown } from './utils/@shutdown' | ||
|
||
// ... | ||
|
||
// setup graceful shutdown | ||
handleShutdown({ | ||
// 3000ms timeout to complete all shutdown tasks (default - 5000) | ||
timeout: 3000 | ||
}) | ||
``` | ||
|
||
### Shutdown callbacks | ||
|
||
```Typescript | ||
import { handleShutdown, onShutdown } from './utils/@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](/LICENSE) by [Sergey Zwezdin](https://github.com/sergeyzwezdin). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"name": "@relab/graceful-shutdown", | ||
"version": "0.0.1", | ||
"description": "Graceful shutdown for Node.js application", | ||
"packageManager": "pnpm@9.1.4", | ||
"main": "lib/index.cjs.js", | ||
"module": "lib/index.esm.js", | ||
"types": "lib/index.d.ts", | ||
"exports": { | ||
"require": "./lib/index.cjs.js", | ||
"import": "./lib/index.esm.js" | ||
}, | ||
"files": [ | ||
"lib/**/*.*" | ||
], | ||
"scripts": { | ||
"preinstall": "npx only-allow pnpm", | ||
"prepublish": "pnpm run build", | ||
"prepack": "pnpm run build", | ||
"build": "rollup -c", | ||
"lint": "eslint . --ext ts,tsx", | ||
"format": "prettier --write \"**/*.ts*\"" | ||
}, | ||
"homepage": "https://github.com/relab-services/node-graceful-shutdown#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/relab-services/node-graceful-shutdown.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/relab-services/node-graceful-shutdown/issues" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
}, | ||
"keywords": [ | ||
"node", | ||
"graceful-shutdown" | ||
], | ||
"author": "Sergey Zwezdin", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=18.20.3" | ||
}, | ||
"devDependencies": { | ||
"@relab/eslint-config": "^2.2.3", | ||
"@relab/prettier-config": "^1.1.3", | ||
"@relab/semantic-release-commits-config": "^1.0.8", | ||
"@rollup/plugin-commonjs": "^25.0.8", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"@semantic-release/git": "^10.0.1", | ||
"@semantic-release/github": "^10.0.5", | ||
"@types/js-yaml": "^4.0.9", | ||
"@types/node": "^20.14.0", | ||
"eslint": "^9.4.0", | ||
"rollup": "^4.18.0", | ||
"rollup-plugin-copy": "^3.5.0", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"rollup-plugin-dts": "^6.1.1", | ||
"rollup-plugin-peer-deps-external": "^2.2.4", | ||
"semantic-release": "^24.0.0", | ||
"semantic-release-pnpm": "^1.0.2", | ||
"semantic-release-telegram-bot": "^2.0.1", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.4.5" | ||
}, | ||
"prettier": "@relab/prettier-config", | ||
"eslintConfig": { | ||
"extends": "@relab/eslint-config/node", | ||
"ignorePatterns": [ | ||
"lib" | ||
] | ||
} | ||
} |
Oops, something went wrong.