Hello !
I have created a meteor app with option --minimal.
Then i tried to use node.js cluster like this :
import { Meteor } from "meteor/meteor";
Meteor.startup(() => {
let cluster = require('cluster');
if (cluster.isMaster) {
let worker = cluster.fork();
worker.on('exit', function() {
console.log("Worker id " + worker.id + " exited.");
});
}
if (cluster.isWorker) {
console.log("Hello. I am worker number " + cluster.worker.id);
}
});
And it’s not working, i really don’t understand why but it’s giving me this error :
I20181208-16:39:48.813(1)? Hello. I am worker number 1
W20181208-16:39:48.841(1)? (STDERR) events.js:183
W20181208-16:39:48.844(1)? (STDERR) throw er; // Unhandled 'error' event
W20181208-16:39:48.848(1)? (STDERR) ^
W20181208-16:39:48.849(1)? (STDERR)
W20181208-16:39:48.851(1)? (STDERR) Error: bind EADDRINUSE 0.0.0.0:28202
W20181208-16:39:48.856(1)? (STDERR) at Object._errnoException (util.js:992:11)
W20181208-16:39:48.858(1)? (STDERR) at _exceptionWithHostPort (util.js:1014:20)
W20181208-16:39:48.859(1)? (STDERR) at listenOnMasterHandle (net.js:1415:16)
W20181208-16:39:48.861(1)? (STDERR) at shared (internal/cluster/child.js:115:3)
W20181208-16:39:48.863(1)? (STDERR) at Worker.send (internal/cluster/child.js:86:7)
W20181208-16:39:48.865(1)? (STDERR) at process.onInternalMessage (internal/cluster/utils.js:42:8)
W20181208-16:39:48.867(1)? (STDERR) at emitTwo (events.js:131:20)
W20181208-16:39:48.869(1)? (STDERR) at process.emit (events.js:214:7)
W20181208-16:39:48.870(1)? (STDERR) at emit (internal/child_process.js:772:12)
W20181208-16:39:48.871(1)? (STDERR) at _combinedTickCallback (internal/process/next_tick.js:141:11)
W20181208-16:39:48.875(1)? (STDERR) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
I20181208-16:39:48.877(1)? Worker id 1 exited.
NB: I also tried to use import cluster instead of require but it doesn’t change anthing.
If you have any idea, i would greatly appreciate your help on this !