Skip to content

Commit d4d2678

Browse files
committed
Fixed annoying port of undefined exception during cluster startup. The problem was in port check that only master should do
1 parent 298c80b commit d4d2678

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,17 @@ Cluster.prototype.listen = function(createApp, cb) {
184184
process.exit(-1);
185185
}
186186
});
187-
server.listen(port[index], host, function() { //'listening' listener
188-
exitIfBusyPort(host, port, index-1, function(){
189-
server.close();
190-
cb();
191-
})
192-
});
187+
if (require('cluster').isMaster) {
188+
server.listen(port[index], host, function() { //'listening' listener
189+
exitIfBusyPort(host, port, index-1, function(){
190+
server.close();
191+
cb();
192+
})
193+
});
194+
}
195+
else {
196+
process.nextTick(cb);
197+
}
193198
}
194199

195200
return self;

0 commit comments

Comments
 (0)