Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster-Support #413

Open
Anachron opened this issue Oct 19, 2014 · 6 comments
Open

Cluster-Support #413

Anachron opened this issue Oct 19, 2014 · 6 comments

Comments

@Anachron
Copy link
Contributor

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.

@dbashford
Copy link
Owner

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.

@Anachron
Copy link
Contributor Author

Woops, I mean I do want to use it. Typo :)

@Anachron
Copy link
Contributor Author

Ping @dbashford :)

@dbashford
Copy link
Owner

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.

@Anachron
Copy link
Contributor Author

You don't like me 😢
Well I'm surely giving mimosa-server-cluster a shot.
Hope it is easy to implement since mimosa is so flexible 👍

@dbashford
Copy link
Owner

Take mimosa-server, remove all the defaultServer stuff (the inside-mimosa hosting), leave the rest, but expect an array back. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants