From c212fef06d77f29c3e0df22897a577567ff181bb Mon Sep 17 00:00:00 2001 From: dskvr Date: Sun, 17 Mar 2024 01:24:44 +0100 Subject: [PATCH] check counts instead of using drained event --- apps/nocapd/src/daemon.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/nocapd/src/daemon.js b/apps/nocapd/src/daemon.js index ffe90230..4688e094 100644 --- a/apps/nocapd/src/daemon.js +++ b/apps/nocapd/src/daemon.js @@ -29,6 +29,14 @@ const populateQueue = async () => { await $q.checker.resetProgressCounts() } +const checkQueue = async () => { + const counts = await $q.checker.counts() + const enqueue = counts.prioritized + counts.active + if(enqueue > 0) return + log.info(`drained: ${$q.queue.name}`) + await populateQueue() +} + const initWorker = async () => { const connection = RedisConnectionDetails() const concurrency = config?.nocapd?.bullmq?.worker?.concurrency? config.nocapd.bullmq.worker.concurrency: 1 @@ -42,7 +50,8 @@ const initWorker = async () => { .drain() await $q.obliterate().catch(()=>{}) setInterval( syncRelaysIn, timestring(config?.nocapd?.seed?.options?.events?.interval, "ms") || timestring("1h", "ms")) - $q.events.on('drained', populateQueue) + setInterval( checkQueue, timestring( "1m", "ms" )) + // $q.events.on('drained', populateQueue) await populateQueue() $q.resume() log.info(`initialized: ${$q.queue.name}`)