Browse Source

Add Application state logging to the microservice package

dev
David Ludwig 4 years ago
parent
commit
9f0499eee6
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      packages/microservice/src/Microservice.ts

+ 4
- 0
packages/microservice/src/Microservice.ts View File

@ -101,10 +101,12 @@ export class Microservice
try {
// Boot the microservice
console.log("Booting services...");
this.state = MicroserviceState.Booting;
await this.boot();
// Start the microservice
console.log("Starting services...");
this.state = MicroserviceState.Starting
await this.onStart();
for (let InternalService of Object.values(this.services)) {
@ -116,11 +118,13 @@ export class Microservice
}
// Run the microservice
console.log("Running");
this.state = MicroserviceState.Running;
process.on("SIGINT", this.quit.bind(this));
let exitCode = await new Promise<number>((resolve) => this.__quitHandler = resolve);
// Shutdown the microservice
console.log("Shutting down...");
await this.shutdown().catch(() => {
console.log("Error ocurred during shutdown...");
exitCode = 1;


Loading…
Cancel
Save