fork-named-cluster

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

Usage no npm install needed!

<script type="module">
  import forkNamedCluster from 'https://cdn.skypack.dev/fork-named-cluster';
</script>

README

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