egg-cluster
Advanced tools
Comparing version 1.6.0 to 1.6.1
1.6.1 / 2017-03-03 | ||
================== | ||
* fix: sticky logic error (#19) | ||
* feat: use egg-utils (#18) | ||
1.6.0 / 2017-03-01 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -109,3 +109,2 @@ 'use strict'; | ||
const ws = Array.from(this.workers.keys()); | ||
const wsd = ws.map(w => w % workerNumbers); | ||
@@ -119,6 +118,3 @@ let s = ''; | ||
s = Number(s); | ||
const idx = wsd.indexOf(s % workerNumbers); | ||
const pid = ws[idx]; | ||
const pid = ws[s % workerNumbers]; | ||
return this.workers.get(pid); | ||
@@ -125,0 +121,0 @@ } |
@@ -7,3 +7,5 @@ 'use strict'; | ||
const assert = require('assert'); | ||
const utils = require('egg-utils'); | ||
module.exports = function(options) { | ||
@@ -28,3 +30,8 @@ const defaults = { | ||
options.framework = getFrameworkPath(options); | ||
options.framework = utils.getFrameworkPath({ | ||
baseDir: options.baseDir, | ||
// compatible customEgg only when call startCluster directly without framework | ||
framework: options.framework || options.customEgg, | ||
}); | ||
const egg = require(options.framework); | ||
@@ -60,31 +67,1 @@ assert(egg.Application, `should define Application in ${options.framework}`); | ||
} | ||
function getFrameworkPath(options) { | ||
const framework = options.customEgg || options.framework; | ||
const moduleDir = path.join(options.baseDir, 'node_modules'); | ||
// 1. pass framework or customEgg | ||
if (framework) { | ||
// 1.1 framework is an absolute path | ||
// framework: path.join(baseDir, 'node_modules/${frameworkName}') | ||
if (path.isAbsolute(framework)) return assertAndReturn(framework); | ||
// 1.2 framework is a npm package that required by application | ||
// framework: 'frameworkName' | ||
return assertAndReturn(path.join(moduleDir, framework)); | ||
} | ||
// 2. framework is not specified | ||
// 2.1 use framework name from pkg.egg.framework | ||
const pkg = require(path.join(options.baseDir, 'package.json')); | ||
if (pkg.egg && pkg.egg.framework) { | ||
return assertAndReturn(path.join(moduleDir, pkg.egg.framework)); | ||
} | ||
// 2.2 use egg by default | ||
return assertAndReturn(path.join(moduleDir, 'egg')); | ||
} | ||
function assertAndReturn(frameworkPath) { | ||
assert(fs.existsSync(frameworkPath), `${frameworkPath} should exist`); | ||
return frameworkPath; | ||
} |
{ | ||
"name": "egg-cluster", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "cluster manager for egg", | ||
@@ -39,2 +39,3 @@ "main": "index.js", | ||
"egg-logger": "^1.5.0", | ||
"egg-utils": "^2.1.0", | ||
"get-ready": "^2.0.1", | ||
@@ -46,5 +47,5 @@ "sendmessage": "^1.1.0" | ||
"coffee": "^3.3.0", | ||
"egg": "^1.0.0-rc.1", | ||
"egg": "^1.0.0-rc.2", | ||
"egg-bin": "^2.2.3", | ||
"egg-ci": "^1.2.0", | ||
"egg-ci": "^1.3.0", | ||
"egg-mock": "^3.0.1", | ||
@@ -51,0 +52,0 @@ "eslint": "^3.16.1", |
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
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
12
27829
8
661
+ Addedegg-utils@^2.1.0
+ Addedegg-utils@2.5.0(transitive)