diff --git a/packages/core/server/src/application.ts b/packages/core/server/src/application.ts index 74fce85b8..739cb4e67 100644 --- a/packages/core/server/src/application.ts +++ b/packages/core/server/src/application.ts @@ -172,6 +172,8 @@ export class Application exten declare middleware: any; + stopped: boolean = false; + constructor(public options: ApplicationOptions) { super(); this.init(); @@ -434,6 +436,7 @@ export class Application exten } await this.emitAsync('afterStart', this, options); + this.stopped = false; } listen(...args): Server { @@ -441,6 +444,11 @@ export class Application exten } async stop(options: any = {}) { + if (this.stopped) { + this.log.warn(`Application ${this.name} already stopped`); + return; + } + await this.emitAsync('beforeStop', this, options); try { @@ -460,6 +468,7 @@ export class Application exten } await this.emitAsync('afterStop', this, options); + this.stopped = true; } async destroy(options: any = {}) {