egg-cluster
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -27,3 +27,3 @@ 'use strict'; | ||
const debug = require('debug')('egg-cluster'); | ||
const debug = require('util').debuglog('egg-cluster'); | ||
const ConsoleLogger = require('egg-logger').EggConsoleLogger; | ||
@@ -30,0 +30,0 @@ const consoleLogger = new ConsoleLogger({ level: process.env.EGG_AGENT_WORKER_LOGGER_LEVEL }); |
@@ -20,3 +20,3 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const debug = require('debug')('egg-cluster'); | ||
const debug = require('util').debuglog('egg-cluster'); | ||
const ConsoleLogger = require('egg-logger').EggConsoleLogger; | ||
@@ -23,0 +23,0 @@ const consoleLogger = new ConsoleLogger({ |
@@ -13,3 +13,2 @@ 'use strict'; | ||
const utility = require('utility'); | ||
const { mkdirp } = require('mz-modules'); | ||
@@ -41,2 +40,3 @@ const Manager = require('./utils/manager'); | ||
* - {String} [pidFile] will save master pid to this file | ||
* - {String} [env] custom env, default is process.env.EGG_SERVER_ENV | ||
*/ | ||
@@ -51,3 +51,3 @@ constructor(options) { | ||
this.isProduction = isProduction(); | ||
this.isProduction = isProduction(this.options); | ||
this.agentWorkerIndex = 0; | ||
@@ -62,3 +62,3 @@ this.closed = false; | ||
this.logMethod = 'info'; | ||
if (process.env.EGG_SERVER_ENV === 'local' || process.env.NODE_ENV === 'development') { | ||
if (this.options.env === 'local' || process.env.NODE_ENV === 'development') { | ||
this.logMethod = 'debug'; | ||
@@ -91,3 +91,3 @@ } | ||
this.log('[master] start with env: isProduction: %s, EGG_SERVER_ENV: %s, NODE_ENV: %s', | ||
this.isProduction, process.env.EGG_SERVER_ENV, process.env.NODE_ENV); | ||
this.isProduction, this.options.env, process.env.NODE_ENV); | ||
@@ -158,3 +158,3 @@ const startTime = Date.now(); | ||
if (this.options.pidFile) { | ||
mkdirp.sync(path.dirname(this.options.pidFile)); | ||
fs.mkdirSync(path.dirname(this.options.pidFile), { recursive: true }); | ||
fs.writeFileSync(this.options.pidFile, process.pid.toString(), 'utf-8'); | ||
@@ -595,6 +595,5 @@ } | ||
function isProduction() { | ||
const serverEnv = process.env.EGG_SERVER_ENV; | ||
if (serverEnv) { | ||
return serverEnv !== 'local' && serverEnv !== 'unittest'; | ||
function isProduction(options) { | ||
if (options.env) { | ||
return options.env !== 'local' && options.env !== 'unittest'; | ||
} | ||
@@ -601,0 +600,0 @@ return process.env.NODE_ENV === 'production'; |
'use strict'; | ||
const debug = require('debug')('egg-cluster:messenger'); | ||
const debug = require('util').debuglog('egg-cluster:messenger'); | ||
const workerThreads = require('worker_threads'); | ||
@@ -5,0 +5,0 @@ |
'use strict'; | ||
const sleep = require('mz-modules/sleep'); | ||
const { sleep } = require('../../../timer'); | ||
const workerThreads = require('worker_threads'); | ||
@@ -5,0 +5,0 @@ const { BaseAppWorker, BaseAppUtils } = require('../../base/app'); |
@@ -21,2 +21,3 @@ 'use strict'; | ||
ports: [], | ||
env: null, | ||
}; | ||
@@ -27,2 +28,5 @@ options = extend(defaults, options); | ||
} | ||
if (!options.env && process.env.EGG_SERVER_ENV) { | ||
options.env = process.env.EGG_SERVER_ENV; | ||
} | ||
@@ -29,0 +33,0 @@ const pkgPath = path.join(options.baseDir, 'package.json'); |
'use strict'; | ||
const sleep = require('mz-modules/sleep'); | ||
const { sleep } = require('./timer'); | ||
const awaitEvent = require('await-event'); | ||
@@ -5,0 +5,0 @@ const pstree = require('ps-tree'); |
{ | ||
"name": "egg-cluster", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "cluster manager for egg", | ||
@@ -9,4 +9,4 @@ "main": "index.js", | ||
"test": "npm run lint -- --fix && npm run test-local", | ||
"test-local": "egg-bin test", | ||
"cov": "egg-bin cov --prerequire --timeout 100000", | ||
"test-local": "egg-bin test --ts false", | ||
"cov": "egg-bin cov --prerequire --timeout 100000 --ts false", | ||
"ci": "npm run lint && npm run cov" | ||
@@ -37,6 +37,5 @@ }, | ||
"cluster-reload": "^1.0.2", | ||
"debug": "^4.1.1", | ||
"depd": "^2.0.0", | ||
"detect-port": "^1.3.0", | ||
"egg-logger": "^2.3.2", | ||
"egg-logger": "^3.3.0", | ||
"egg-utils": "^2.4.1", | ||
@@ -46,3 +45,2 @@ "get-ready": "^2.0.1", | ||
"is-type-of": "^1.2.1", | ||
"mz-modules": "^2.1.0", | ||
"ps-tree": "^1.2.0", | ||
@@ -57,3 +55,3 @@ "semver": "^5.6.0", | ||
"egg": "^3.9.0", | ||
"egg-bin": "^5.6.1", | ||
"egg-bin": "^6.4.0", | ||
"egg-errors": "^2.2.0", | ||
@@ -63,7 +61,6 @@ "egg-mock": "^5.4.0", | ||
"eslint-config-egg": "^12.1.0", | ||
"mz": "^2.7.0", | ||
"pedding": "^1.1.0", | ||
"supertest": "^4.0.0", | ||
"ts-node": "^6.0.3", | ||
"typescript": "^2.7.2" | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -70,0 +67,0 @@ "engines": { |
# egg-cluster | ||
[![NPM version][npm-image]][npm-url] | ||
[![CI](https://github.com/eggjs/egg-cluster/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-cluster/actions/workflows/nodejs.yml) | ||
[![Test coverage][codecov-image]][codecov-url] | ||
@@ -17,3 +18,3 @@ [![Known Vulnerabilities][snyk-image]][snyk-url] | ||
Cluster Manager for Egg | ||
Cluster Manager for EggJS | ||
@@ -25,3 +26,3 @@ --- | ||
```bash | ||
$ npm i egg-cluster --save | ||
npm i egg-cluster --save | ||
``` | ||
@@ -62,2 +63,3 @@ | ||
| ports | `Array` | startup port of each app worker, such as: [7001, 7002, 7003], only effects when the startMode is 'worker_threads' | | ||
| env | `String` | custom env, default is process.env.EGG_SERVER_ENV | | ||
@@ -64,0 +66,0 @@ ## Env |
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
57701
14
12
18
1712
72
26
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedegg-logger@3.6.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedutility@2.1.0(transitive)
- Removeddebug@^4.1.1
- Removedmz-modules@^2.1.0
- Removedansi-styles@3.2.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removedegg-logger@2.9.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedko-sleep@1.1.4(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.0.0(transitive)
- Removedmz-modules@2.1.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsupports-color@5.5.0(transitive)
Updatedegg-logger@^3.3.0