mimosa
mimosa copied to clipboard
Cluster-Support
I would like to create something like this: https://github.com/rowanmanning/learning-express-cluster/blob/master/app.js
// Include the cluster module
var cluster = require('cluster');
// Code to run if we're in the master process
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;
// Create a worker for each CPU
for (var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
// Listen for dying workers
cluster.on('exit', function (worker) {
// Replace the dead worker, we're not sentimental
console.log('Worker ' + worker.id + ' died :(');
cluster.fork();
});
// Code to run if we're in a worker process
} else {
// Include Express
var express = require('express');
// Create a new Express application
var app = express();
// Add a basic route – index page
app.get('/', function (req, res) {
res.send('Hello from Worker ' + cluster.worker.id);
});
// Bind to a port
app.listen(3000);
console.log('Worker ' + cluster.worker.id + ' running!');
}
But sadly mimosa can only handle one server instance. Is it possible to accept multiple servers for the callback?
Edit: I know this is possible by using a custom server, however, I do not want to use all the server-reload and such functionality that come by mimosa modules.
You do NOT want to use server reload?
If you don't want to use server/live-reload, then there's no need to bother handing your server back.
Woops, I mean I do want to use it. Typo :)
Ping @dbashford :)
Pong!
Not going to happen in short order I'm afraid. I'm not going to edit mimosa-server or mimosa-server-reload, which I assume are the important ones. I'd rather create a mimosa-server-cluster that focuses on that issue. Ditto mimosa-server-cluster-reload. Welcome to give that a shot.
You don't like me :cry: Well I'm surely giving mimosa-server-cluster a shot. Hope it is easy to implement since mimosa is so flexible :+1:
Take mimosa-server, remove all the defaultServer stuff (the inside-mimosa hosting), leave the rest, but expect an array back. =)