Permalink
Browse files

Fixed bug when using cluster(filename), previously still requireing f…

…or master
  • Loading branch information...
1 parent f684321 commit f231ff00da08d1bb38645aaf69ed0b2487876540 @tj tj committed Mar 1, 2011
Showing with 13 additions and 3 deletions.
  1. +12 −0 lib/master.js
  2. +0 −3 lib/worker.js
  3. +1 −0 test/test.filename.js
View
@@ -219,14 +219,26 @@ Master.prototype.call = function(id, method){
Master.prototype.listen = function(port, host, callback){
var self = this;
+
+ // prevent listen
if (this.preventDefault) return;
+
+ // env match
if (this.environmentMatches) {
+ // worker process
if (this.isWorker) {
+ // resolve server filename
+ if ('string' == typeof this.server) {
+ this.server = require(this.resolve(this.server));
+ }
+
+ // connect the worker
var worker = new Worker(this);
this.sock = net.createConnection(this.socketPath);
this.sock.on('connect', function(){
worker.start();
});
+ // master process
} else {
this.port = port;
if ('function' == typeof host) callback = host, host = null;
View
@@ -40,9 +40,6 @@ var node = process.execPath;
var Worker = module.exports = function Worker(master) {
this.master = master;
this.server = master.server;
- if ('string' == typeof this.server) {
- this.server = require(master.resolve(this.server));
- }
};
/**
View
@@ -10,6 +10,7 @@ require('./common');
cluster = cluster('support/exported')
+ .set('workers', 4)
.listen(3000);
cluster.on('listening', function(){

0 comments on commit f231ff0

Please sign in to comment.