Skip to content

Instantly share code, notes, and snippets.

@lenconda
Created February 25, 2019 01:17
Show Gist options
  • Save lenconda/9a7fad0e0133a4f9de8726bce8d963d7 to your computer and use it in GitHub Desktop.
Save lenconda/9a7fad0e0133a4f9de8726bce8d963d7 to your computer and use it in GitHub Desktop.
Node.js child_process.fork()
console.log(`Child process running with ${process.pid}`)
setInterval(() => {
process.send(`Worker got time: ${Date.parse(new Date())}`)
}, 1000)
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