mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-12 15:52:32 +10:00
cleanup indicators
This commit is contained in:
@ -17,21 +17,14 @@ export class PostgresHealthIndicator extends HealthIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async pingCheck(key: string): Promise<HealthIndicatorResult> {
|
async pingCheck(key: string): Promise<HealthIndicatorResult> {
|
||||||
let isHealthy = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sql`SELECT 1=1`.execute(this.db);
|
await sql`SELECT 1=1`.execute(this.db);
|
||||||
isHealthy = true;
|
return this.getStatus(key, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(JSON.stringify(e));
|
this.logger.error(JSON.stringify(e));
|
||||||
}
|
|
||||||
|
|
||||||
if (isHealthy) {
|
|
||||||
return this.getStatus(key, isHealthy);
|
|
||||||
} else {
|
|
||||||
throw new HealthCheckError(
|
throw new HealthCheckError(
|
||||||
`${key} is not available`,
|
`${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> {
|
async pingCheck(key: string): Promise<HealthIndicatorResult> {
|
||||||
let isHealthy = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const redis = new Redis(this.environmentService.getRedisUrl(), {
|
const redis = new Redis(this.environmentService.getRedisUrl(), {
|
||||||
maxRetriesPerRequest: 15,
|
maxRetriesPerRequest: 15,
|
||||||
});
|
});
|
||||||
|
|
||||||
await redis.ping();
|
await redis.ping();
|
||||||
isHealthy = true;
|
return this.getStatus(key, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(e);
|
this.logger.error(e);
|
||||||
}
|
|
||||||
|
|
||||||
if (isHealthy) {
|
|
||||||
return this.getStatus(key, isHealthy);
|
|
||||||
} else {
|
|
||||||
throw new HealthCheckError(
|
throw new HealthCheckError(
|
||||||
`${key} is not available`,
|
`${key} is not available`,
|
||||||
this.getStatus(key, isHealthy),
|
this.getStatus(key, false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user