Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…or master
  • Loading branch information...
commit f231ff00da08d1bb38645aaf69ed0b2487876540 1 parent f684321
@tj tj authored
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
12 lib/master.js
@@ -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
3  lib/worker.js
@@ -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
1  test/test.filename.js
@@ -10,6 +10,7 @@ require('./common');
cluster = cluster('support/exported')
+ .set('workers', 4)
.listen(3000);
cluster.on('listening', function(){
Please sign in to comment.
Something went wrong with that request. Please try again.