egg 3.11.1 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/middleware/site_file.js +5 -3
- package/lib/egg.js +6 -3
- package/package.json +2 -3
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
5
|
module.exports = options => {
|
|
6
|
-
return function siteFile(ctx, next) {
|
|
6
|
+
return async function siteFile(ctx, next) {
|
|
7
7
|
if (ctx.method !== 'HEAD' && ctx.method !== 'GET') return next();
|
|
8
8
|
/* istanbul ignore if */
|
|
9
9
|
if (ctx.path[0] !== '/') return next();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
let content = options[ctx.path];
|
|
12
12
|
if (!content) return next();
|
|
13
13
|
|
|
14
|
-
// '/favicon.ico': 'https://eggjs.org/favicon.ico'
|
|
14
|
+
// '/favicon.ico': 'https://eggjs.org/favicon.ico' or '/favicon.ico': async (ctx) => 'https://eggjs.org/favicon.ico'
|
|
15
|
+
// content is function
|
|
16
|
+
if (typeof content === 'function') content = await content(ctx);
|
|
15
17
|
// content is url
|
|
16
18
|
if (typeof content === 'string') return ctx.redirect(content);
|
|
17
19
|
|
package/lib/egg.js
CHANGED
|
@@ -417,11 +417,13 @@ class EggApplication extends EggCore {
|
|
|
417
417
|
const rundir = this.config.rundir;
|
|
418
418
|
const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`);
|
|
419
419
|
fs.writeFileSync(dumpFile, CircularJSON.stringify(items, null, 2));
|
|
420
|
+
this.coreLogger.info(this.timing.toString());
|
|
420
421
|
// only disable, not clear bootstrap timing data.
|
|
421
422
|
this.timing.disable();
|
|
422
423
|
// show duration >= ${slowBootActionMinDuration}ms action to warnning log
|
|
423
424
|
for (const item of items) {
|
|
424
|
-
|
|
425
|
+
// ignore #0 name: Process Start
|
|
426
|
+
if (item.index > 0 && item.duration >= this.config.dump.timing.slowBootActionMinDuration) {
|
|
425
427
|
this.coreLogger.warn('[egg:core][slow-boot-action] #%d %dms, name: %s',
|
|
426
428
|
item.index, item.duration, item.name);
|
|
427
429
|
}
|
|
@@ -437,10 +439,11 @@ class EggApplication extends EggCore {
|
|
|
437
439
|
|
|
438
440
|
_setupTimeoutTimer() {
|
|
439
441
|
const startTimeoutTimer = setTimeout(() => {
|
|
442
|
+
this.coreLogger.error(this.timing.toString());
|
|
440
443
|
this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`);
|
|
441
444
|
// log unfinished
|
|
442
|
-
const
|
|
443
|
-
for (const item of
|
|
445
|
+
const items = this.timing.toJSON();
|
|
446
|
+
for (const item of items) {
|
|
444
447
|
if (item.end) continue;
|
|
445
448
|
this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`);
|
|
446
449
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egg",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"tag": "latest"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"delegates": "^1.0.0",
|
|
29
29
|
"egg-cluster": "^2.0.0",
|
|
30
30
|
"egg-cookies": "^2.6.1",
|
|
31
|
-
"egg-core": "^5.
|
|
31
|
+
"egg-core": "^5.3.0",
|
|
32
32
|
"egg-development": "^2.7.0",
|
|
33
33
|
"egg-errors": "^2.3.1",
|
|
34
34
|
"egg-i18n": "^2.1.1",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"@umijs/preset-react": "^2.1.6",
|
|
65
65
|
"address": "^1.2.1",
|
|
66
66
|
"antd": "^4.23.2",
|
|
67
|
-
"assert-extends": "^1.0.1",
|
|
68
67
|
"assert-file": "^1.0.0",
|
|
69
68
|
"coffee": "^5.4.0",
|
|
70
69
|
"dumi": "^1.1.47",
|