@david.uhlir/cluster
TypeScript icon, indicating that this package has built-in type declarations

2.0.10 • Public • Published

Cluster util for node.js

This utility is for handle run forks of application with specific initializators. It also provides method calling between fork and master provided as promises.

This util is also checking all forks by ping to know their health. If the response is too long it will restart/kill them - depends on configuration

Usage

import { Cluster, MasterHandler } from '@david.uhlir/cluster'

const workers = Cluster.Initialize({
  worker: async () => ({
    sayHello: () => console.log('Hello world PID:', process.pid)
  }),
})

MasterHandler.Initialize(async () => {
  console.log('Initialize PID:', process.pid)
  const handler = await workers.run.worker()
  await handler.call.sayHello()
})

ISC

Package Sidebar

Install

npm i @david.uhlir/cluster

Weekly Downloads

24

Version

2.0.10

License

ISC

Unpacked Size

55.1 MB

Total Files

321

Last publish

Collaborators

  • david.uhlir