From 6cd41f98609769c067662c130f6340caca7938b8 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Mon, 4 Feb 2019 16:41:53 +0900 Subject: [PATCH] Initialize queue only if queue is enabled (#4125) --- src/queue/index.ts | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/queue/index.ts b/src/queue/index.ts index d1237435b..65c52d864 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -7,19 +7,27 @@ import { program } from '../argv'; const enableQueue = config.redis != null && !program.disableQueue; -const queue = new Queue('misskey', { - redis: { - port: config.redis.port, - host: config.redis.host, - password: config.redis.pass - }, +const queue = initializeQueue(); - removeOnSuccess: true, - removeOnFailure: true, - getEvents: false, - sendEvents: false, - storeJobs: false -}); +function initializeQueue() { + if (enableQueue) { + return new Queue('misskey', { + redis: { + port: config.redis.port, + host: config.redis.host, + password: config.redis.pass + }, + + removeOnSuccess: true, + removeOnFailure: true, + getEvents: false, + sendEvents: false, + storeJobs: false + }); + } else { + return null; + } +} export function createHttpJob(data: any) { if (enableQueue) {