Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Better multiply CPU support #2265

Closed
AndreasMadsen opened this issue Dec 4, 2011 · 3 comments
Closed

Better multiply CPU support #2265

AndreasMadsen opened this issue Dec 4, 2011 · 3 comments
Labels

Comments

@AndreasMadsen
Copy link
Member

When working with multiply machines (I have never done that so I'm just guessing) no a machine should be able to go online without restrating the cluster.

To support multiply machines you need to know when a CPU is gone offline or added:

//A CPU is added or removed
require('os').on('CPUchange', function (change) {

 //A list of cores 
 change.forEach(function (CPUcore) {
   //If a CPU is appended new workers should be forked 
   if (change.isAppended) {
      cluster.fork();
    } else if (change.isRemoved) {
      //this is bad
    }
  });
});

And know what CPU and/or core the process is running on:

var workers = [require('child_process').fork('worker.js')];
var system = new Setup(); //Custom system from userland

//Disconnect worker
system.on('takeofCPU', function (cpu, callback) {

  //Seach the workers list and disconnect the worker when a CPU ID match is found
  workers.forEach(function (worker) {
   if (worker.cpu.id === cpu.id) {
     worker.disconnect(callback);
   }
  });
});

This is to be used in cluster 2.0 ( see: #2038 ).

@AndreasMadsen
Copy link
Member Author

This would properly also help sorting out issue #1329 , since we won't have to make continuously check the cpus().length.

@Prinzhorn
Copy link

I was just browsing through old issues. Can't this be closed since #2038 and all related cluster 2.0 PRs are closed?

@bnoordhuis
Copy link
Member

I guess so. Closing.

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

No branches or pull requests

3 participants