Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Added multi-processor support for cube servers #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions bin/collector.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
var options = require("./collector-config"),
var cluster = require('cluster'),
options = require("./collector-config"),
cube = require("../"),
server = cube.server(options);

server.register = function(db, endpoints) {
cube.collector.register(db, endpoints);
};
var numCPUs = options.workers || require('os').cpus().length;

server.start();
if (cluster.isMaster) {
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
cluster.fork();
});
} else {
server.register = function(db, endpoints) {
cube.collector.register(db, endpoints);
};

server.start();
}
24 changes: 19 additions & 5 deletions bin/evaluator.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
var options = require("./evaluator-config"),
var cluster = require('cluster'),
options = require("./evaluator-config"),
cube = require("../"),
server = cube.server(options);

server.register = function(db, endpoints) {
cube.evaluator.register(db, endpoints);
};
var numCPUs = options.workers || require('os').cpus().length;

server.start();
if (cluster.isMaster) {
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
cluster.fork();
});
} else {
server.register = function(db, endpoints) {
cube.evaluator.register(db, endpoints);
};

server.start();
}