egg-cluster
Advanced tools
Comparing version 0.0.4 to 0.1.0
0.1.0 / 2016-08-16 | ||
================== | ||
* feat: [BREAKING_CHANGE] master won't load config (#4) | ||
* test: add test cases (#3) | ||
0.0.4 / 2016-07-16 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -16,3 +16,2 @@ 'use strict'; | ||
plugins: options.plugins, | ||
customEgg: options.customEgg, | ||
}); | ||
@@ -19,0 +18,0 @@ agent.ready(() => process.send({ action: 'agent-start', to: 'master' })); |
@@ -11,3 +11,2 @@ 'use strict'; | ||
const app = new Application({ | ||
customEgg: options.customEgg, | ||
baseDir: options.baseDir, | ||
@@ -14,0 +13,0 @@ plugins: options.plugins, |
@@ -13,3 +13,2 @@ 'use strict'; | ||
const MasterLoader = require('./utils/loader'); | ||
const parseOptions = require('./utils/options'); | ||
@@ -26,9 +25,8 @@ const Messenger = require('./utils/messenger'); | ||
* @param {Object} options | ||
* - {String} [eggPath] - egg framework path | ||
* - {String} [customEgg] - customized egg framework, default to `eggPath` | ||
* - {String} [baseDir] application code directory, default to `process.cwd()` | ||
* - {Object} [plugins] - customized plugins, for test purpose | ||
* - {String} [customEgg] - directory of framework | ||
* - {String} [baseDir] directory of application, default to `process.cwd()` | ||
* - {Object} [plugins] - customized plugins, for unittest | ||
* - {Number} [workers] numbers of app workers, default to `os.cpus().length` | ||
* - {Number} [port] listening port, default to 7001(http) or 8443(https) | ||
* - {Boolean} [https] https or hot | ||
* - {Boolean} [https] https or not | ||
* - {String} [key] ssl key | ||
@@ -44,16 +42,9 @@ * - {String} [cert] ssl cert | ||
const loader = new MasterLoader(this.options); | ||
const config = loader.loadConfig(); | ||
this.isProduction = config.env !== 'local' && config.env !== 'unittest'; | ||
this.isProduction = isProduction(); | ||
// app started or not | ||
this.isStarted = false; | ||
this.logger = new ConsoleLogger({ level: 'INFO' }); | ||
this.logger = new ConsoleLogger({ | ||
errorFile: path.join(config.logger.dir, config.logger.errorLogName), | ||
level: 'INFO', | ||
encoding: config.logger.encoding, | ||
}); | ||
// get the real framework info | ||
const frameworkPath = options.customEgg || options.eggPath; | ||
const frameworkPath = options.customEgg; | ||
const frameworkPkg = require(path.join(frameworkPath, 'package.json')); | ||
@@ -357,1 +348,9 @@ | ||
} | ||
function isProduction() { | ||
const serverEnv = process.env.EGG_SERVER_ENV; | ||
if (serverEnv) { | ||
return serverEnv !== 'local' && serverEnv !== 'unittest'; | ||
} | ||
return process.env.NODE_ENV === 'production'; | ||
} |
@@ -10,7 +10,5 @@ 'use strict'; | ||
customEgg: '', | ||
eggPath: '', | ||
baseDir: process.cwd(), | ||
port: options.https ? 8443 : 7001, | ||
workers: null, | ||
antxpath: '', | ||
plugins: null, | ||
@@ -26,11 +24,7 @@ https: false, | ||
assert(options.eggPath && fs.existsSync(options.eggPath), 'options.eggPath should exists'); | ||
const egg = require(options.eggPath); | ||
assert(options.customEgg && fs.existsSync(options.customEgg), 'options.customEgg is required'); | ||
const egg = require(options.customEgg); | ||
assert(egg.Application, 'should define Application in customEgg'); | ||
assert(egg.Agent, 'should define Agent in customEgg'); | ||
if (!options.customEgg) { | ||
options.customEgg = options.eggPath; | ||
} | ||
if (options.https) { | ||
@@ -37,0 +31,0 @@ assert(options.key && fs.existsSync(options.key), 'options.key should exists'); |
{ | ||
"name": "egg-cluster", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "cluster manager for egg", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "egg-bin test", | ||
"test": "npm run lint && npm run test-local", | ||
"test-local": "egg-bin test", | ||
"cov": "egg-bin cov", | ||
"lint": "eslint --ext js . --fix", | ||
"ci": "npm run lint && npm run cov", | ||
"autod": "autod" | ||
@@ -26,7 +30,6 @@ }, | ||
"dependencies": { | ||
"egg-loader": "^0.0.2", | ||
"egg-logger": "^1.0.0", | ||
"cfork": "^1.5.1", | ||
"cluster-reload": "^1.0.2", | ||
"debug": "^2.2.0", | ||
"egg-logger": "^1.2.0", | ||
"get-ready": "^1.0.0", | ||
@@ -36,7 +39,13 @@ "sendmessage": "^1.0.5" | ||
"devDependencies": { | ||
"autod": "^2.6.1", | ||
"egg-bin": "^1.0.1", | ||
"autod": "^2.7.0", | ||
"coffee": "^3.2.4", | ||
"egg": "*", | ||
"egg-bin": "^1.2.0", | ||
"egg-ci": "^1.0.2", | ||
"eslint": "^3.0.1", | ||
"eslint-config-egg": "^3.0.1" | ||
"egg-mock": "*", | ||
"eslint": "^3.3.1", | ||
"eslint-config-egg": "^3.1.0", | ||
"pedding": "^1.0.0", | ||
"should": "^10.0.0", | ||
"supertest": "^1.2.0" | ||
}, | ||
@@ -43,0 +52,0 @@ "engines": { |
@@ -1,2 +0,2 @@ | ||
# egg-logger | ||
# egg-cluster | ||
@@ -23,3 +23,3 @@ [![NPM version][npm-image]][npm-url] | ||
Egg cluster. | ||
Cluster Manager for Egg | ||
@@ -36,6 +36,34 @@ --- | ||
TBD | ||
```js | ||
const startCluster = require('egg-cluster').startCluster; | ||
startCluster({ | ||
baseDir: '/path/to/app', | ||
customEgg: '/path/to/framework', | ||
}); | ||
``` | ||
You can specify a callback that will be invoked when application has started. However, master process will exit when catch an error. | ||
```js | ||
startCluster(options, () => { | ||
console.log('started'); | ||
}); | ||
``` | ||
## Options | ||
| Param | Type | Description | | ||
| --------- | --------- | ------------------------ | | ||
| baseDir | `String` | directory of application | | ||
| customEgg | `String` | directory of framework | | ||
| plugins | `Object` | plugins for unittest | | ||
| workers | `Number` | numbers of app workers | | ||
| port | `Number` | port | | ||
| https | `Boolean` | start a https server | | ||
| key | `String` | ssl key | | ||
| cert | `String` | ssl cert | | ||
## License | ||
[MIT](LICENSE) | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
46679
6
90
1371
68
11
15
5
- Removedegg-loader@^0.0.2
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedasync@0.9.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedegg-loader@0.0.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedglob@5.0.15(transitive)
- Removedglobby@2.0.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinterop-require@1.0.0(transitive)
- Removedis-class-hotfix@0.0.6(transitive)
- Removedis-type-of@1.4.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedloading@1.13.3(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedobject-assign@2.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedegg-logger@^1.2.0