From 0455abce2e9916cc1ad0d3375b3894b789c13623 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Mon, 24 Mar 2025 01:10:27 +0800 Subject: [PATCH] fix: did not quit when job is already workingx --- lib/mq/exec/snapshotTick.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/mq/exec/snapshotTick.ts b/lib/mq/exec/snapshotTick.ts index 8fd7247..7eb93e2 100644 --- a/lib/mq/exec/snapshotTick.ts +++ b/lib/mq/exec/snapshotTick.ts @@ -133,7 +133,11 @@ export const collectMilestoneSnapshotsWorker = async (_job: Job) => { export const regularSnapshotsWorker = async (_job: Job) => { const client = await db.connect(); const startedAt = Date.now(); - await lockManager.acquireLock("dispatchRegularSnapshots"); + if (await lockManager.isLocked("dispatchRegularSnapshots")) { + logger.log("dispatchRegularSnapshots is already running", "mq"); + return; + } + await lockManager.acquireLock("dispatchRegularSnapshots", 30 * 60); try { const aids = await getVideosWithoutActiveSnapshotSchedule(client); for (const rawAid of aids) {