import { redis } from "@/services/redis";
import { loggerModule } from "@/utils/logger";

const shutdownLogger = loggerModule("shutdown");

export function setupShutdown() {
    process.on("SIGINT", shutdown);
    process.on("SIGTERM", shutdown);
}

async function shutdown() {
    shutdownLogger.info("Shutting down...");
    shutdownLogger.info("Closing Redis connection...");
    await redis.quit();
    process.exit(0);
}
