Socket
Socket
Sign inDemoInstall

cluster-harakiri

Package Overview
Dependencies
2
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cluster-harakiri

Controls creation and removal of workers at a regular interval


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
58.4 kB
Created
Weekly downloads
 

Readme

Source

npm version CI workflow

Cluster Harakiri

This library provides a wrapper around the standard node cluster module. The library will automatically terminate and restart cluster workers based on time or connections. These parameters can be configured for the particular use case using environmental variables or programmatic initialization.

Prerequisites

This project requires NodeJS (version 16 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
8.15.0
v16.17.0

Table of contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Installation

BEFORE YOU INSTALL: please read the prerequisites

To install and set up the library, run:

$ npm install cluster-harakiri

Or if you prefer using Yarn:

$ yarn add cluster-harakiri

Usage

Start with cloning this repo on your local machine:

$ git clone https://github.com/smartfile/node-cluster-harakiri.git
$ cd node-cluster-harakiri

Running the tests

$ npm test

Running the linter

$ npm run lint

API

setupHarakiri

setupHarakiri(options)

Supported options and result fields for the setupHarakiri method are listed below. Most options are also available as environmental variables. It is not necessary to call this method. Options can be set in the environment and this method will be called if not already called when workers are created.

Options

ttl

TypeDefault valueEnvironmental variable
numberHARAKIRI_WORKER_TTL

If present, the workers will be terminated after at least ttl seconds.

connectionLimit

TypeDefault valueEnvironmental variable
numberHARAKIRI_WORKER_CONN_LIMIT

If present, the workers will be terminated after at least connectionLimit connections.

checkInterval

TypeDefault valueEnvironmental variable
number30HARAKIRI_WORKER_CHECK_INTERVAL

The periodic interval, in seconds, to check if there are any workers to terminate.

termDelay

TypeDefault valueEnvironmental variable
numberHARAKIRI_WORKER_TERM_DELAY

If present, the amount of time to delay, in seconds, between terminating workers. This can be used to prevent many or all workers from being terminated at the same time.

closeTimeout

TypeDefault valueEnvironmental variable
numberHARAKIRI_WORKER_CLOSE_TIMEOUT

If present, the amount of time, in seconds, to wait for the worker to exit after termination. This can be used to prevent a worker from running indefinitely if the connection stays alive.

restartWorker

TypeDefault valueEnvironmental variable
booleantrue

If true, creates a new worker when a worker terminates.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request :sunglasses:

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

MIT License © SmartFile

Keywords

FAQs

Last updated on 26 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc