node-cluster-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Node Cluster Utils

Install

$ npm install https://github.com/4000D/node-cluster-utils.git

implemente nodejs app and run with pm2 cluster mode.

Usage

const { withLock } = require("node-cluster-utils");

withLock({
  // lockFilePath: "path/to/lock/file",
  f: () => {
    setInterval(() => {
      console.log("hello", process.pid);
    }, 1000);

    return new Promise(() => {}); // run 1 node instance acquire lock forever
  },
});
import { withLock } from "node-cluster-utils";

withLock({
  // lockFilePath: "path/to/lock/file",
  f: () => {
    setInterval(() => {
      console.log("hello", process.pid);
    }, 1000);

    return new Promise<void>(() => {}); // run 1 node instance acquire lock forever
  },
});

Readme

Keywords

none

Package Sidebar

Install

npm i node-cluster-utils

Weekly Downloads

1

Version

0.0.2

License

ISC

Unpacked Size

21.8 kB

Total Files

14

Last publish

Collaborators

  • 4000d