Skip to content

Commit 53eee76

Browse files
committed
環境変数から Worker を選べるようにする
1 parent 001649b commit 53eee76

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/backend/src/queue/QueueProcessorService.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,20 @@ export class QueueProcessorService implements OnApplicationShutdown {
206206
//#endregion
207207

208208
//#region deliver
209-
this.deliverQueueWorkers = this.config.redisForDeliverQueues.map(config => new Bull.Worker(QUEUE.DELIVER, (job) => this.deliverProcessorService.process(job), {
210-
...baseWorkerOptions(config, this.config.bullmqWorkerOptions, QUEUE.DELIVER),
211-
autorun: false,
212-
concurrency: this.config.deliverJobConcurrency ?? 128,
213-
limiter: {
214-
max: this.config.deliverJobPerSec ?? 128,
215-
duration: 1000,
216-
},
217-
settings: {
218-
backoffStrategy: httpRelatedBackoff,
219-
},
220-
}));
209+
this.deliverQueueWorkers = this.config.redisForDeliverQueues
210+
.filter((_, index) => process.env.QUEUE_WORKER_INDEX == null || index === Number.parseInt(process.env.QUEUE_WORKER_INDEX, 10))
211+
.map(config => new Bull.Worker(QUEUE.DELIVER, (job) => this.deliverProcessorService.process(job), {
212+
...baseWorkerOptions(config, this.config.bullmqWorkerOptions, QUEUE.DELIVER),
213+
autorun: false,
214+
concurrency: this.config.deliverJobConcurrency ?? 128,
215+
limiter: {
216+
max: this.config.deliverJobPerSec ?? 128,
217+
duration: 1000,
218+
},
219+
settings: {
220+
backoffStrategy: httpRelatedBackoff,
221+
},
222+
}));
221223

222224
this.deliverQueueWorkers.forEach((worker, index) => {
223225
const deliverLogger = this.logger.createSubLogger(`deliver-${index}`);

0 commit comments

Comments
 (0)