Skip to content

Commit

Permalink
fix for cluster config. nextTick => setImmediate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Messbauer committed Nov 19, 2013
1 parent 973e7f7 commit c54524e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Expand Up @@ -45,6 +45,10 @@ var Main = function(mixdown, options) {
this.options = options;
};

Main.prototype.stop = function(callback) {
throw new Error('stop() not implemented on server. TODO.');
};

Main.prototype.start = function(callback) {
var that = this;
var mixdown = this.mixdown;
Expand Down Expand Up @@ -76,7 +80,7 @@ Main.prototype.start = function(callback) {

// Start cluster.
var children = this.workers;
var clusterConfig = mixdown.main.cluster || {};
var clusterConfig = mixdown.main.options.cluster || {};

if(clusterConfig.on){
logger.info("Using cluster");
Expand Down Expand Up @@ -108,12 +112,12 @@ Main.prototype.start = function(callback) {
process.exit();
}
else {
process.nextTick(checkExit); // keep polling for safe shutdown.
setImmediate(checkExit); // keep polling for safe shutdown.
}
};

// poll the master and exit when children are all gone.
process.nextTick(checkExit);
setImmediate(checkExit);

});

Expand Down

0 comments on commit c54524e

Please sign in to comment.