Last active
September 9, 2018 10:48
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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