Created
February 25, 2019 01:17
-
-
Save lenconda/9a7fad0e0133a4f9de8726bce8d963d7 to your computer and use it in GitHub Desktop.
Node.js child_process.fork()
This file contains hidden or 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
console.log(`Child process running with ${process.pid}`) | |
setInterval(() => { | |
process.send(`Worker got time: ${Date.parse(new Date())}`) | |
}, 1000) |
This file contains hidden or 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
const child_process = require('child_process') | |
let child = child_process.fork('./child.js') | |
child.on('message', function(message) { | |
console.log('PARENT got message:', message) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment