Skip to content

Commit

Permalink
Add logging for infrastructure status checks in Status.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Nov 20, 2024
1 parent b14f918 commit 972e6cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Common/Server/Infrastructure/Status.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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");
}
}
}

0 comments on commit 972e6cb

Please sign in to comment.