Update redis-health.ts

This commit is contained in:
Nicolas
2024-08-02 17:43:45 -04:00
parent 2e83a8a8b4
commit 39aecd974b
+10 -11
View File
@@ -1,7 +1,6 @@
import { Request, Response } from "express"; import { Request, Response } from "express";
import Redis from "ioredis"; import Redis from "ioredis";
import { Logger } from "../../lib/logger"; import { Logger } from "../../lib/logger";
import { sendSlackWebhook } from "../../services/alerts/slack";
import { redisRateLimitClient } from "../../services/rate-limiter"; import { redisRateLimitClient } from "../../services/rate-limiter";
export async function redisHealthController(req: Request, res: Response) { export async function redisHealthController(req: Request, res: Response) {
@@ -63,22 +62,22 @@ export async function redisHealthController(req: Request, res: Response) {
Logger.info( Logger.info(
`Redis instances health check: ${JSON.stringify(healthStatus)}` `Redis instances health check: ${JSON.stringify(healthStatus)}`
); );
await sendSlackWebhook( // await sendSlackWebhook(
`[REDIS DOWN] Redis instances health check: ${JSON.stringify( // `[REDIS DOWN] Redis instances health check: ${JSON.stringify(
healthStatus // healthStatus
)}`, // )}`,
true // true
); // );
return res return res
.status(500) .status(500)
.json({ status: "unhealthy", details: healthStatus }); .json({ status: "unhealthy", details: healthStatus });
} }
} catch (error) { } catch (error) {
Logger.error(`Redis health check failed: ${error}`); Logger.error(`Redis health check failed: ${error}`);
await sendSlackWebhook( // await sendSlackWebhook(
`[REDIS DOWN] Redis instances health check: ${error.message}`, // `[REDIS DOWN] Redis instances health check: ${error.message}`,
true // true
); // );
return res return res
.status(500) .status(500)
.json({ status: "unhealthy", message: error.message }); .json({ status: "unhealthy", message: error.message });