Browse Source

Add additional stage to microservice internal service to link to other internal services

dev
David Ludwig 4 years ago
parent
commit
0d6069c0d2
2 changed files with 15 additions and 3 deletions
  1. +8
    -1
      packages/microservice/src/InternalService.ts
  2. +7
    -2
      packages/microservice/src/Microservice.ts

+ 8
- 1
packages/microservice/src/InternalService.ts View File

@ -45,7 +45,14 @@ export abstract class InternalService<T extends Microservice = Microservice> ext
// no-op
}
// Miscellaneous ------------------------------------------------------------------------------
// Miscellaneous ------------------------------------------------------------------------------
/**
* Link to local services
*/
public link(app: T) {
// no-op
}
/**
* Indicate the application is ready


+ 7
- 2
packages/microservice/src/Microservice.ts View File

@ -105,12 +105,17 @@ export class Microservice
this.state = MicroserviceState.Booting;
await this.boot();
// Linking the internal services
for (let service of Object.values(this.service)) {
service.link(this);
}
// Start the microservice
console.log("Starting services...");
this.state = MicroserviceState.Starting
await this.onStart();
for (let InternalService of Object.values(this.services)) {
InternalService.start();
for (let service of Object.values(this.services)) {
service.start();
}
} catch(e) {
console.error("Failed to start the microservice:", e);


Loading…
Cancel
Save