mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-03 02:16:51 +00:00
b89f5071e5
* After installing Parsoid (sudo npm install -g in modules/parser), run 'node server.js' from the api directory and navigate to http://localhost:8000/ and follow the directions. You can start to navigate the English wikipedia at http://localhost:8000/Main_Page, or manually enter wikitext or HTML DOM to convert. * Uses the express framework, could also use just connect * Uses the cluster module to manage workers per-core and restart those on failure Change-Id: I443f2996ed3df00826b038b7476a2f966ab0c425
24 lines
519 B
JavaScript
24 lines
519 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;
|
|
|
|
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);
|
|
}
|