Skip to content

Instantly share code, notes, and snippets.

@NiklasGollenstede
Last active September 9, 2018 10:48
Show Gist options
  • Save NiklasGollenstede/1c17f213659615b5e9c1f66923f3b740 to your computer and use it in GitHub Desktop.
Save NiklasGollenstede/1c17f213659615b5e9c1f66923f3b740 to your computer and use it in GitHub Desktop.
wtfnode #29: Show more information on cluster worker ipc "Pipe" (node v8.9.3 and v10.8.0)
'use strict';
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork(); return;
}
const wtfnode = require('wtfnode');
wtfnode.dump();
console.log(
`process.channel === process._getActiveHandles()[0]`,
process.channel === process._getActiveHandles()[0],
); // if stdio is defined, it seems to be at index 1 and 2
console.log(
`process.channel instanceof process.binding('pipe_wrap').Pipe`,
process.channel instanceof process.binding('pipe_wrap').Pipe,
);
if (process.argv[2] === 'debug') {
global.wtfnode = wtfnode;
require('inspector').open();
} else {
process.disconnect();
}
{
"author": "Niklas Gollenstede",
"license": "MIT",
"main": "./cluster-pipe-wtfnode-test.js",
"dependencies": {
"wtfnode": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment