Centralize archive deletion loop; stagger different centralized loops slightly
This commit is contained in:
parent
2d84a02d48
commit
617a4ea7fc
4 changed files with 44 additions and 18 deletions
12
backend/src/data/loops/expiredArchiveDeletionLoop.ts
Normal file
12
backend/src/data/loops/expiredArchiveDeletionLoop.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { lazyMemoize, MINUTES } from "../../utils";
|
||||
import { Archives } from "../Archives";
|
||||
import moment from "moment-timezone";
|
||||
|
||||
const LOOP_INTERVAL = 15 * MINUTES;
|
||||
const getArchivesRepository = lazyMemoize(() => new Archives());
|
||||
|
||||
export async function runExpiredArchiveDeletionLoop() {
|
||||
console.log("[EXPIRED ARCHIVE DELETION LOOP] Deleting expired archives");
|
||||
await getArchivesRepository().deleteExpiredArchives();
|
||||
setTimeout(() => runExpiredArchiveDeletionLoop(), LOOP_INTERVAL);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue