Add logging for infrastructure status checks in Status.ts

This commit is contained in:
Simon Larsen 2024-11-20 21:33:32 +00:00
parent b14f918d59
commit 972e6cb98f
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA

View File

@ -1,4 +1,5 @@
// This class checks the status of all the datasources.
import logger from "../Utils/Logger";
import { ClickhouseAppInstance } from "./ClickhouseDatabase";
import PostgresAppInstance from "./PostgresDatabase";
import Redis from "./Redis";
@ -10,22 +11,33 @@ export default class InfrastructureStatus {
checkPostgresStatus: boolean;
checkClickhouseStatus: boolean;
}): Promise<void> {
logger.debug("Checking infrastructure status");
if (data.checkRedisStatus) {
logger.debug("Checking Redis status");
if (!(await Redis.checkConnnectionStatus())) {
logger.debug("Redis is not connected");
throw new DatabaseNotConnectedException("Redis is not connected");
}
logger.debug("Redis is connected");
}
if (data.checkPostgresStatus) {
logger.debug("Checking Postgres status");
if (!(await PostgresAppInstance.checkConnnectionStatus())) {
logger.debug("Postgres is not connected");
throw new DatabaseNotConnectedException("Postgres is not connected");
}
logger.debug("Postgres is connected");
}
if (data.checkClickhouseStatus) {
logger.debug("Checking Clickhouse status");
if (!(await ClickhouseAppInstance.checkConnnectionStatus())) {
logger.debug("Clickhouse is not connected");
throw new DatabaseNotConnectedException("Clickhouse is not connected");
}
logger.debug("Clickhouse is connected");
}
}
}