cleanup indicators
This commit is contained in:
parent
f12f93b373
commit
a0536d852f
2 changed files with 4 additions and 18 deletions
|
|
@ -17,21 +17,14 @@ export class PostgresHealthIndicator extends HealthIndicator {
|
|||
}
|
||||
|
||||
async pingCheck(key: string): Promise<HealthIndicatorResult> {
|
||||
let isHealthy = false;
|
||||
|
||||
try {
|
||||
await sql`SELECT 1=1`.execute(this.db);
|
||||
isHealthy = true;
|
||||
return this.getStatus(key, true);
|
||||
} catch (e) {
|
||||
this.logger.error(JSON.stringify(e));
|
||||
}
|
||||
|
||||
if (isHealthy) {
|
||||
return this.getStatus(key, isHealthy);
|
||||
} else {
|
||||
throw new HealthCheckError(
|
||||
`${key} is not available`,
|
||||
this.getStatus(key, isHealthy),
|
||||
this.getStatus(key, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,18 @@ export class RedisHealthIndicator extends HealthIndicator {
|
|||
}
|
||||
|
||||
async pingCheck(key: string): Promise<HealthIndicatorResult> {
|
||||
let isHealthy = false;
|
||||
|
||||
try {
|
||||
const redis = new Redis(this.environmentService.getRedisUrl(), {
|
||||
maxRetriesPerRequest: 15,
|
||||
});
|
||||
|
||||
await redis.ping();
|
||||
isHealthy = true;
|
||||
return this.getStatus(key, true);
|
||||
} catch (e) {
|
||||
this.logger.error(e);
|
||||
}
|
||||
|
||||
if (isHealthy) {
|
||||
return this.getStatus(key, isHealthy);
|
||||
} else {
|
||||
throw new HealthCheckError(
|
||||
`${key} is not available`,
|
||||
this.getStatus(key, isHealthy),
|
||||
this.getStatus(key, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue