From 39392a793db6015a91dc38a59ac4def910756fd6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 Jul 2024 16:57:32 +0100 Subject: [PATCH 1/2] 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) } From ac2b87df9edcb6224f7b9dd9c019159ba885238c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 2 Jul 2024 16:59:42 +0100 Subject: [PATCH 2/2] Quick change. --- packages/server/src/appMigrations/index.ts | 1 - packages/server/src/appMigrations/queue.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/src/appMigrations/index.ts b/packages/server/src/appMigrations/index.ts index de15666215..5ee92543f0 100644 --- a/packages/server/src/appMigrations/index.ts +++ b/packages/server/src/appMigrations/index.ts @@ -49,7 +49,6 @@ export async function checkMissingMigrations( const queue = getAppMigrationQueue() if ( - queue && latestMigration && getTimestamp(currentVersion) < getTimestamp(latestMigration) ) { diff --git a/packages/server/src/appMigrations/queue.ts b/packages/server/src/appMigrations/queue.ts index 12f301da0e..d06d039fd0 100644 --- a/packages/server/src/appMigrations/queue.ts +++ b/packages/server/src/appMigrations/queue.ts @@ -13,7 +13,7 @@ export type AppMigrationJob = { // 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( +const appMigrationQueue = queue.createQueue( queue.JobQueue.APP_MIGRATION, { jobOptions: {