diff --git a/backend/src/index.ts b/backend/src/index.ts index cb37e197f..d1379c04f 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -97,14 +97,17 @@ import { githubPushEventSecretScan } from "./queues/secret-scanning/githubScanPu const SmeeClient = require("smee-client"); // eslint-disable-line import path from "path"; import { serverConfigInit } from "./config/serverConfig"; +import { initRedis } from "./services/RedisService"; let handler: null | any = null; const main = async () => { await initLogger(); + const port = await getPort(); - // initializing the database connection + // initializing the database connection + redis + await initRedis() await DatabaseService.initDatabase(await getMongoURL()); const serverCfg = await serverConfigInit(); await setup(); diff --git a/backend/src/services/RedisService.ts b/backend/src/services/RedisService.ts index 218234a1a..e439ffb40 100644 --- a/backend/src/services/RedisService.ts +++ b/backend/src/services/RedisService.ts @@ -3,11 +3,14 @@ import { logger } from "../utils/logging"; let redisClient: TRedis | null; -if (process.env.REDIS_URL) { - redisClient = new Redis(process.env.REDIS_URL as string); -} else { - logger.warn("Redis URL not set, skipping Redis initialization."); - redisClient = null; +export const initRedis = async () => { + if (process.env.REDIS_URL) { + redisClient = new Redis(process.env.REDIS_URL as string); + } else { + logger.warn("Redis URL not set, skipping Redis initialization."); + redisClient = null; + } } + export { redisClient }; diff --git a/backend/src/utils/logging/logger.ts b/backend/src/utils/logging/logger.ts index 3e9d82240..7562a8b5b 100644 --- a/backend/src/utils/logging/logger.ts +++ b/backend/src/utils/logging/logger.ts @@ -19,7 +19,7 @@ export const initLogger = async () => { const isProduction = nodeEnv === "production"; const targets: pino.TransportMultiOptions["targets"][number][] = [ isProduction - ? { level: "info", target: "pino/file", options: { destination: 'logs/infisical-backend/logs.txt', mkdir: true } } + ? { level: "info", target: "pino/file", options: {} } : { level: "info", target: "pino-pretty", // must be installed separately