Skip to content

Commit

Permalink
check counts instead of using drained event
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Mar 17, 2024
1 parent 41564ae commit c212fef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/nocapd/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`)
Expand Down

0 comments on commit c212fef

Please sign in to comment.