How to use sails with cluster (to use more cores)?

cluster-computing, node.js, sails.js

Solution

Finally I have used pm2 module for this as mentioned in one of `sails` issues https://github.com/balderdashy/sails/issues/170

One should first install it:

$ npm install -g pm2

and then run the script:

$ pm2 start app.js -i max

then you can monitor it with:

$ pm2 monit

or list the processess:

$ pm2 l

Problem

I am trying to launch sails.js application with `cluster` library to allow it so spawn more processes to use all cores of my machine but somehow the method used with express fails here. ``` var cluster = require('cluster'), numCPUs = require('os').cpus().length; // create the server if (cluster.isMaster) { for (var i = 0; i < numCPUs; i++) { cluster.fork(); } cluster.on('exit', function(worker, code, signal) { console.log('worker %d died (%s). restarting...', worker.process.pid, signal || code); cluster.fork(); }); } else { // Start sails and pass it command line arguments require('sails').lift(require('optimist').argv); console.log("Sails forked"); } ``` After that I just normally run it via : ``` $ sails lift ``` but I get the same results when I run apache bench for this performance testing. Any help ? Am I missing something ? EDIT Even when I put `console.log` in `cluster.fork` if part then I do not get the output.

Original source