Merged in fix/redis-shutdown-graceful (pull request #1969)
Fix/redis shutdown graceful * fix: shutdown redis gracefully when container restarts * throttle scans to redis to avoid overwhelming it Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { loggerModule } from "@/utils/logger";
|
||||
import { redis } from "@/services/redis";
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user