diff --git a/README.md b/README.md index 981df9cf..cb61f61f 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ EggCore record boot progress with `Timing`, include: - Process start time - Script start time(node don't implement an interface like `process.uptime` to record the script start running time, framework can implement a prestart file used with node `--require` options to set `process.scriptTime`) -- Application start time +- `application start` or `agent start` time - Load duration - `require` duration diff --git a/src/lifecycle.ts b/src/lifecycle.ts index d3453371..79093092 100644 --- a/src/lifecycle.ts +++ b/src/lifecycle.ts @@ -85,7 +85,7 @@ export class Lifecycle extends EventEmitter { this.#isClosed = false; this.#init = false; - this.timing.start('Application Start'); + this.timing.start(`${this.options.app.type} Start`); // get app timeout from env or use default timeout 10 second const eggReadyTimeoutEnv = parseInt(process.env.EGG_READY_TIMEOUT_ENV || '10000'); assert( @@ -105,7 +105,7 @@ export class Lifecycle extends EventEmitter { this.ready(err => { this.triggerDidReady(err); debug('app ready'); - this.timing.end('Application Start'); + this.timing.end(`${this.options.app.type} Start`); }); } diff --git a/test/egg.test.ts b/test/egg.test.ts index 394960ec..1fb3cc3b 100644 --- a/test/egg.test.ts +++ b/test/egg.test.ts @@ -18,13 +18,15 @@ describe.skip('test/egg.test.ts', () => { let app: EggCore; after(() => app && app.close()); - it('should set options and _options', () => { + it('should set options and _options', async () => { app = new EggCore(); assert.equal((app as any)._options, undefined); assert.deepEqual(app.options, { baseDir: process.cwd(), type: 'application', }); + await app.loader.loadApplicationExtend(); + await app.ready(); }); it('should use cwd when no options', () => { @@ -214,7 +216,7 @@ describe.skip('test/egg.test.ts', () => { assert(id.includes(file)); const timeline = app.timing.toString(); console.log(timeline); - assert.match(timeline, /▇ \[\d+ms NOT_END] - #1 Application Start/); + assert.match(timeline, /▇ \[\d+ms NOT_END] - #1 application Start/); assert.match(timeline, /▇ \[\d+ms NOT_END] - #14 Before Start in app.js:3:7/); done(); }); @@ -469,7 +471,7 @@ describe.skip('test/egg.test.ts', () => { const json = app.timing.toJSON(); assert(json.length === 28); - assert(json[1].name === 'Application Start'); + assert(json[1].name === 'application Start'); assert(json[1].end! - json[1].start === json[1].duration); assert(json[1].pid === process.pid); @@ -528,7 +530,7 @@ describe.skip('test/egg.test.ts', () => { const json = app.timing.toJSON(); assert(json.length === 14); - assert(json[1].name === 'Application Start'); + assert(json[1].name === 'agent Start'); assert(json[1].end! - json[1].start === json[1].duration); assert(json[1].pid === process.pid); @@ -752,7 +754,7 @@ describe.skip('test/egg.test.ts', () => { ]); console.log(app.timing.toString()); assert.match(app.timing.toString(), /egg start timeline:/); - assert.match(app.timing.toString(), /#1 Application Start/); + assert.match(app.timing.toString(), /#1 application Start/); }); }); diff --git a/test/index.test.ts b/test/index.test.ts index 226b32dc..4c52abe6 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -3,7 +3,7 @@ import * as EggCore from '../src/index.js'; describe('test/index.test.ts', () => { it('should expose properties', () => { - console.log(EggCore); + // console.log(EggCore); assert(EggCore.EggCore); assert(EggCore.EggLoader); assert(EggCore.BaseContextClass);