Comparing version 0.2.4 to 0.2.5
@@ -136,2 +136,29 @@ var util = require('util'), | ||
/** | ||
* @param {*} context | ||
* @param {String} [path] | ||
* @returns {Boolean} `true` if property exists | ||
*/ | ||
function has(context, path) { | ||
if (typeof path === 'undefined' || path === '') { | ||
return context; | ||
} | ||
var props = path.split('.'), | ||
prop = props[0], | ||
i, size, | ||
ctx = context; | ||
for (i = 0, size = props.length; i < size; prop = props[++i]) { | ||
if (typeof ctx === 'undefined' || ctx === null || | ||
! Object.prototype.hasOwnProperty.call(ctx, prop)) { | ||
return false; | ||
} | ||
ctx = ctx[prop]; | ||
} | ||
return true; | ||
} | ||
/** | ||
* @param {String} path to property | ||
@@ -309,2 +336,12 @@ * @param {*} value | ||
/** | ||
* @param {String} path | ||
* @returns {Boolean} | ||
* @see has | ||
* @public | ||
*/ | ||
Configuration.prototype.has = function(path) { | ||
return has(this, path); | ||
}; | ||
/** | ||
* Shortcut for `Object.keys(c.get('some.obj.prop', {}))` | ||
@@ -408,2 +445,2 @@ * @param {String} [path] | ||
module.exports = Configurable; | ||
module.exports = Configurable; |
@@ -199,3 +199,4 @@ var os = require('os'), | ||
count = this.config.get('workers', os.cpus().length), | ||
port = new Port(this.config.get('server.port')), | ||
isServerPortSet = this.config.has('server.port'), | ||
port, | ||
groups = this.config.get('server.groups', 1), | ||
@@ -206,2 +207,6 @@ group = 0, | ||
if (isServerPortSet) { | ||
port = new Port(this.config.get('server.port')); | ||
} | ||
// remove `--debug` option from passed to master | ||
@@ -222,3 +227,3 @@ cluster.setupMaster({ | ||
debugPort : debugPort && debugPort + i - 1, | ||
port : port.next(group), | ||
port : isServerPortSet ? port.next(group) : 0, | ||
_maxListeners : this._maxListeners | ||
@@ -225,0 +230,0 @@ })); |
@@ -1,3 +0,2 @@ | ||
var domain = require('domain'), | ||
cluster = require('cluster'), | ||
var cluster = require('cluster'), | ||
RPC = require('./rpc'), | ||
@@ -47,3 +46,3 @@ ClusterProcess = require('./cluster_process'), | ||
/** | ||
* `Require` application main script inside domain. | ||
* `Require` application main script. | ||
* Execution will be delayed until Worker became configured | ||
@@ -55,22 +54,4 @@ * (`configured` event fired). | ||
Worker.prototype.run = Worker.whenInitialized(function() { | ||
var workerDomain = domain.create(), | ||
workerPath = this.config.resolve('app'); | ||
require(this.config.resolve('app')); | ||
workerDomain.on('error', function(error) { | ||
var message = error; | ||
if (error.stack) { | ||
message += '\n' + error.stack; | ||
} | ||
// @todo: kaero: send notice about happened shit to master? | ||
console.error(message); | ||
process.exit(1); | ||
}); | ||
workerDomain.run(function() { | ||
require(workerPath); | ||
}); | ||
return this; | ||
@@ -77,0 +58,0 @@ }); |
{ | ||
"name" : "luster", | ||
"version" : "0.2.4", | ||
"version" : "0.2.5", | ||
"description" : "Node.js cluster wrapper", | ||
@@ -5,0 +5,0 @@ "main" : "./lib/luster.js", |
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
99010
1833