Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Created March 6, 2014 07:33
Show Gist options
  • Save MarshalW/9384253 to your computer and use it in GitHub Desktop.
Save MarshalW/9384253 to your computer and use it in GitHub Desktop.
var cluster=require('cluster');
if(cluster.isMaster){
console.log('is master');
var worker=cluster.fork();
worker.on('message',function(message){
console.log('master recieve message: '+message);
});
process.on('exit',function(){
console.log('process exit');
});
}else{
console.log('is slave');
setInterval(function(){
process.send('are u ok, master?');
},5000);
}
console.log('end.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment