diff --git a/src/config.ts b/src/config.ts index 016f4182..3df35300 100644 --- a/src/config.ts +++ b/src/config.ts @@ -59,6 +59,7 @@ type StorageConfigType = { logflareApiKey?: string logflareSourceToken?: string pgQueueEnable: boolean + pgQueueEnableWorkers?: boolean pgQueueConnectionURL?: string pgQueueDeleteAfterDays?: number pgQueueArchiveCompletedAfterSeconds?: number @@ -303,6 +304,7 @@ export function getConfig(options?: { reload?: boolean }): StorageConfigType { // Queue pgQueueEnable: getOptionalConfigFromEnv('PG_QUEUE_ENABLE', 'ENABLE_QUEUE_EVENTS') === 'true', + pgQueueEnableWorkers: getOptionalConfigFromEnv('PG_QUEUE_WORKERS_ENABLE') !== 'false', pgQueueConnectionURL: getOptionalConfigFromEnv('PG_QUEUE_CONNECTION_URL'), pgQueueDeleteAfterDays: parseInt( getOptionalConfigFromEnv('PG_QUEUE_DELETE_AFTER_DAYS') || '2', diff --git a/src/queue/queue.ts b/src/queue/queue.ts index c8778869..6710a64b 100644 --- a/src/queue/queue.ts +++ b/src/queue/queue.ts @@ -27,6 +27,7 @@ export abstract class Queue { pgQueueDeleteAfterDays, pgQueueArchiveCompletedAfterSeconds, pgQueueRetentionDays, + pgQueueEnableWorkers, } = getConfig() let url = pgQueueConnectionURL ?? databaseURL @@ -52,7 +53,9 @@ export abstract class Queue { expireInHours: 48, }) - registerWorkers() + if (pgQueueEnableWorkers) { + registerWorkers() + } Queue.pgBoss.on('error', (error) => { logSchema.error(logger, '[Queue] error', {