first commit
This commit is contained in:
14
mApi/cluster.js
Executable file
14
mApi/cluster.js
Executable file
@@ -0,0 +1,14 @@
|
||||
var cluster = require('cluster');
|
||||
if (cluster.isMaster) {
|
||||
//Fork a worker to run the main program
|
||||
for (var i = 0; i < 2; i++) var worker = cluster.fork();
|
||||
} else {
|
||||
//Run main program
|
||||
require('./build/www.js');
|
||||
console.log('worker is running');
|
||||
}
|
||||
|
||||
cluster.on('death', function(worker) {
|
||||
console.log('worker ' + worker.pid + ' died. restart...');
|
||||
cluster.fork();
|
||||
});
|
||||
Reference in New Issue
Block a user