Refactor code structure for improved readability and maintainability
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m20s

This commit is contained in:
2026-03-18 21:23:01 -04:00
parent 8aca2ae14e
commit 3b40f0f869
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -229,7 +229,11 @@ const schedulerWorker = new Worker(
) )
} }
console.log(`[scheduler] queued ${toQueue.length} price-update jobs (${hashtags.length - toQueue.length} already waiting)`) const [waitingAfter, activeAfter] = await Promise.all([
priceUpdateQueue.getWaitingCount(),
priceUpdateQueue.getActiveCount(),
])
console.log(`[scheduler] queued ${toQueue.length} price-update jobs (${hashtags.length - toQueue.length} already waiting) — queue now: waiting=${waitingAfter} active=${activeAfter}`)
}, },
{ connection: redisOpts() }, { connection: redisOpts() },
) )
@@ -247,6 +251,9 @@ for (const [name, worker] of [['price', priceWorker], ['maintenance', maintenanc
} }
// Diagnostic: log when price jobs complete or stall // Diagnostic: log when price jobs complete or stall
priceWorker.on('active', (job) => {
console.log(`[price-worker] active (picked up) job ${job.id} (${job.data?.tag})`)
})
priceWorker.on('completed', (job) => { priceWorker.on('completed', (job) => {
console.log(`[price-worker] completed job ${job.id} (${job.data?.tag})`) console.log(`[price-worker] completed job ${job.id} (${job.data?.tag})`)
}) })
@@ -254,6 +261,16 @@ priceWorker.on('stalled', (jobId) => {
console.warn(`[price-worker] stalled job ${jobId} — lock expired, will retry`) console.warn(`[price-worker] stalled job ${jobId} — lock expired, will retry`)
}) })
// Log queue depths every 30 s so we can see if jobs are piling up or vanishing
setInterval(async () => {
const [waiting, active, failed] = await Promise.all([
priceUpdateQueue.getWaitingCount(),
priceUpdateQueue.getActiveCount(),
priceUpdateQueue.getFailedCount(),
])
console.log(`[price-queue] waiting=${waiting} active=${active} failed=${failed}`)
}, 30_000)
// ── Repeatable jobs ─────────────────────────────────────────────────────────── // ── Repeatable jobs ───────────────────────────────────────────────────────────
async function setupRepeatableJobs() { async function setupRepeatableJobs() {
+1 -1
View File
File diff suppressed because one or more lines are too long