Skip to content

Instantly share code, notes, and snippets.

@wonderdogone
Last active October 22, 2015 20:42
Show Gist options
  • Save wonderdogone/75a7dce4527044a4fddb to your computer and use it in GitHub Desktop.
Save wonderdogone/75a7dce4527044a4fddb to your computer and use it in GitHub Desktop.
const cluster = require('cluster');
if (cluster.isMaster) {
let router = zmq.socket('router').bind('tcp://127.0.0.1:5433');
// forward messages between router and dealer
router.on('message', function() {
//send to worker
});
for (let i = 0; i < 4; i++) {
cluster.fork();
}
} else {
let worker = zmq.socket('rep').connect('ipc://filer-dealer.ipc');
worker.on('message', function(data) {
//dowork
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment