mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 09:04:21 +00:00
e2ee66e532
Change-Id: I7381e09ead0420d5d0b8c7dd3045c88c3cbfaa87
24 lines
523 B
JavaScript
24 lines
523 B
JavaScript
/**
|
|
* A very basic cluster-based server runner. Restarts failed workers, but does
|
|
* not much else right now.
|
|
*/
|
|
|
|
var cluster = require('cluster');
|
|
var app = require('./ParserService.js');
|
|
var numCPUs = require('os').cpus().length + 3;
|
|
|
|
if (cluster.isMaster) {
|
|
// Fork workers.
|
|
for (var i = 0; i < numCPUs; i++) {
|
|
cluster.fork();
|
|
}
|
|
|
|
cluster.on('death', function(worker) {
|
|
console.log('worker ' + worker.pid + ' died, restarting.');
|
|
// restart worker
|
|
cluster.fork();
|
|
});
|
|
} else {
|
|
app.listen(8000);
|
|
}
|