chore: move saved message clean-up loop with other global loops
This commit is contained in:
parent
394573318d
commit
72d5d9d17a
3 changed files with 17 additions and 15 deletions
14
backend/src/data/loops/savedMessageCleanupLoop.ts
Normal file
14
backend/src/data/loops/savedMessageCleanupLoop.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { MINUTES } from "../../utils";
|
||||
import { cleanupMessages } from "../cleanup/messages";
|
||||
|
||||
const LOOP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
export async function runSavedMessageCleanupLoop() {
|
||||
try {
|
||||
console.log("[SAVED MESSAGE CLEANUP LOOP] Deleting old/deleted messages from the database");
|
||||
const deleted = await cleanupMessages();
|
||||
console.log(`[SAVED MESSAGE CLEANUP LOOP] Deleted ${deleted} old/deleted messages from the database`);
|
||||
} finally {
|
||||
setTimeout(() => runSavedMessageCleanupLoop(), LOOP_INTERVAL);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue