Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log app start timeline on coreLogger #5122

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,13 @@ class EggApplication extends EggCore {
const rundir = this.config.rundir;
const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`);
fs.writeFileSync(dumpFile, CircularJSON.stringify(items, null, 2));
this.coreLogger.info(this.timing.toString());
// only disable, not clear bootstrap timing data.
this.timing.disable();
// show duration >= ${slowBootActionMinDuration}ms action to warnning log
for (const item of items) {
if (item.duration >= this.config.dump.timing.slowBootActionMinDuration) {
// ignore #0 name: Process Start
if (item.index > 0 && item.duration >= this.config.dump.timing.slowBootActionMinDuration) {
this.coreLogger.warn('[egg:core][slow-boot-action] #%d %dms, name: %s',
item.index, item.duration, item.name);
}
Expand All @@ -437,10 +439,11 @@ class EggApplication extends EggCore {

_setupTimeoutTimer() {
const startTimeoutTimer = setTimeout(() => {
this.coreLogger.error(this.timing.toString());
this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`);
// log unfinished
const json = this.timing.toJSON();
for (const item of json) {
const items = this.timing.toJSON();
for (const item of items) {
if (item.end) continue;
this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"delegates": "^1.0.0",
"egg-cluster": "^2.0.0",
"egg-cookies": "^2.6.1",
"egg-core": "^5.1.1",
"egg-core": "^5.3.0",
"egg-development": "^2.7.0",
"egg-errors": "^2.3.1",
"egg-i18n": "^2.1.1",
Expand Down
3 changes: 1 addition & 2 deletions test/app/middleware/override_method.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const utils = require('../../utils');

describe('test/app/middleware/override_method.test.js', () => {
Expand Down Expand Up @@ -29,6 +27,7 @@ describe('test/app/middleware/override_method.test.js', () => {
});

it('should delete', () => {
app.mockCsrf();
return app.httpRequest()
.post('/test')
.send({ _method: 'DELETE' })
Expand Down