Skip to content

Commit

Permalink
fix(health): fix health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed May 13, 2024
1 parent 368649a commit 0a375c0
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,32 +254,31 @@ export class Worker {
implementation: this.fulfillmentCommandInterface,
} as BindConfig<CommandInterfaceServiceDefinition>);

// Add reflection service
const reflectionServiceName = serviceNamesCfg.reflection;
const reflectionService = buildReflectionService([
{ descriptor: FulfillmentMeta.fileDescriptor as any },
{ descriptor: FulfillmentCourierMeta.fileDescriptor as any },
{ descriptor: FulfillmentProductMeta.fileDescriptor as any },
]);

await this.server.bind(reflectionServiceName, {
service: ServerReflectionService,
implementation: reflectionService
});

await this.server.bind(serviceNamesCfg.health, {
service: HealthDefinition,
implementation: new Health(
this.fulfillmentCommandInterface,
{
logger,
cfg,
dependencies: [],
readiness: async () => !!await (db as Arango).db.version()
dependencies: ['acs-srv'],
readiness: () => (db as Arango).db.version().then(v => !!v)
}
)
} as BindConfig<HealthDefinition>);

// Add reflection service
const reflectionService = buildReflectionService([
{ descriptor: FulfillmentMeta.fileDescriptor as any },
{ descriptor: FulfillmentCourierMeta.fileDescriptor as any },
{ descriptor: FulfillmentProductMeta.fileDescriptor as any },
]);

await this.server.bind(serviceNamesCfg.reflection, {
service: ServerReflectionService,
implementation: reflectionService
});

// start server
await this.server.start();
this.logger.info('server started successfully');
Expand All @@ -288,9 +287,17 @@ export class Worker {
async stop(): Promise<any> {
this.logger.info('Shutting down');
await Promise.allSettled([
this.server?.stop(),
this.events?.stop(),
this.offsetStore?.stop(),
this.events?.stop().catch(
error => this.logger?.error(error)
)
]);
await Promise.allSettled([
this.server?.stop().catch(
error => this.logger?.error(error)
),
this.offsetStore?.stop().catch(
error => this.logger?.error(error)
),
]);
}
}

0 comments on commit 0a375c0

Please sign in to comment.