From 39392a793db6015a91dc38a59ac4def910756fd6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 Jul 2024 16:57:32 +0100 Subject: [PATCH] Making sure the app migration queue is created correctly consistently. --- packages/server/src/appMigrations/queue.ts | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/server/src/appMigrations/queue.ts b/packages/server/src/appMigrations/queue.ts index e2bc4406f1..12f301da0e 100644 --- a/packages/server/src/appMigrations/queue.ts +++ b/packages/server/src/appMigrations/queue.ts @@ -11,26 +11,26 @@ export type AppMigrationJob = { appId: string } -let appMigrationQueue: queue.Queue | undefined +// always create app migration queue - so that events can be pushed and read from it +// across the different api and automation services +let appMigrationQueue = queue.createQueue( + queue.JobQueue.APP_MIGRATION, + { + jobOptions: { + attempts: MAX_ATTEMPTS, + removeOnComplete: true, + removeOnFail: true, + }, + maxStalledCount: MAX_ATTEMPTS, + removeStalledCb: async (job: Job) => { + logging.logAlert( + `App migration failed, queue job ID: ${job.id} - reason: ${job.failedReason}` + ) + }, + } +) export function init() { - appMigrationQueue = queue.createQueue( - queue.JobQueue.APP_MIGRATION, - { - jobOptions: { - attempts: MAX_ATTEMPTS, - removeOnComplete: true, - removeOnFail: true, - }, - maxStalledCount: MAX_ATTEMPTS, - removeStalledCb: async (job: Job) => { - logging.logAlert( - `App migration failed, queue job ID: ${job.id} - reason: ${job.failedReason}` - ) - }, - } - ) - return appMigrationQueue.process(MIGRATION_CONCURRENCY, processMessage) }