Comparing version 0.5.2 to 0.5.3
var cluster = require('cluster'), | ||
RPC = require('./rpc'), | ||
ClusterProcess = require('./cluster_process'), | ||
legacy = require('./legacy'), | ||
Worker; | ||
@@ -28,2 +29,5 @@ | ||
this._foreignPropertiesReceived = false; | ||
this.on('foreign properties received', (function() { this._foreignPropertiesReceived = true; }).bind(this)); | ||
this.on('extension loaded', broadcastEvent.bind(this, 'extension loaded')); | ||
@@ -68,5 +72,21 @@ this.on('configured', broadcastEvent.bind(this, 'configured')); | ||
}, this); | ||
this.emit('foreign properties received'); | ||
}; | ||
/** | ||
* @param {Function} fn | ||
*/ | ||
Worker.whenForeignPropertiesReceived = function(fn) { | ||
return /** @this {Worker} */function() { | ||
if (this._foreignPropertiesReceived) { | ||
legacy.setImmediate(fn.bind(this)); | ||
} else { | ||
this.once('foreign properties received', fn.bind(this)); | ||
} | ||
return this; | ||
}; | ||
}; | ||
/** | ||
* `Require` application main script. | ||
@@ -78,8 +98,12 @@ * Execution will be delayed until Worker became configured | ||
*/ | ||
Worker.prototype.run = Worker.whenInitialized(function() { | ||
require(this.config.resolve('app')); | ||
Worker.prototype.run = Worker.whenInitialized( | ||
Worker.whenForeignPropertiesReceived(function() { | ||
var workerBase = this.config.resolve('app'); | ||
return this; | ||
}); | ||
require(workerBase); | ||
this.emit('worker loaded', workerBase); | ||
return this; | ||
})); | ||
/** | ||
@@ -86,0 +110,0 @@ * @override |
{ | ||
"name" : "luster", | ||
"version" : "0.5.2", | ||
"version" : "0.5.3", | ||
"description" : "Node.js cluster wrapper", | ||
@@ -5,0 +5,0 @@ "main" : "./lib/luster.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
108761
1982