fork-named-cluster
TypeScript icon, indicating that this package has built-in type declarations

1.2.7 • Public • Published

fork-named-cluster

you can fork your cluster with custom process name as filename.

when you has multi-cluster, It will be make you debug easier.

usage

/// your-worker-file
setTimeout(()=>{
    process.emit("MY_CUSTOM_READY_EVENT", {say:"hi"})
});
import { forkCluster, forkChildProcess } from 'fork-named-cluster';
// or
const { forkCluster, forkChildProcess } = require('fork-named-cluster');
 
 
forkCluster(require.resolve('./your-worker-file'), {
    process_name:"custom-process-name"
});
 
const { wait_ready } = forkChildProcess(require.resolve('./your-worker-file'), {
    ready_event: "MY_CUSTOM_READY_EVENT",
    process_name:"custom-process-name"
});
const ready_data = await wait_ready;// {say:"hi"}

and you can get your process name by:

process[Symbol.for('name')]
process.name
process.env.name

DEMO

it is my demo code:

image

and run it as --inspect-brk, then open your chrome://inspect.

you can see:

image

Readme

Keywords

none

Package Sidebar

Install

npm i fork-named-cluster

Weekly Downloads

16

Version

1.2.7

License

MIT

Unpacked Size

8.43 kB

Total Files

4

Last publish

Collaborators

  • kezhaofeng