diff options
Diffstat (limited to 'src/queue/index.ts')
| -rw-r--r-- | src/queue/index.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/queue/index.ts b/src/queue/index.ts index cf8af17a48..161b8f9b24 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -4,13 +4,15 @@ import config from '../config'; import { ILocalUser } from '../models/user'; import { program } from '../argv'; import handler from './processors'; +import { queueLogger } from './logger'; -const enableQueue = config.redis != null && !program.disableQueue; +const enableQueue = !program.disableQueue; +const queueAvailable = config.redis != null; const queue = initializeQueue(); function initializeQueue() { - if (enableQueue) { + if (queueAvailable) { return new Queue('misskey', { redis: { port: config.redis.port, @@ -30,7 +32,7 @@ function initializeQueue() { } export function createHttpJob(data: any) { - if (enableQueue) { + if (queueAvailable) { return queue.createJob(data) .retries(4) .backoff('exponential', 16384) // 16s @@ -52,7 +54,7 @@ export function deliver(user: ILocalUser, content: any, to: any) { } export function createExportNotesJob(user: ILocalUser) { - if (!enableQueue) throw 'queue disabled'; + if (!queueAvailable) throw 'queue unavailable'; return queue.createJob({ type: 'exportNotes', @@ -62,7 +64,10 @@ export function createExportNotesJob(user: ILocalUser) { } export default function() { - if (enableQueue) { + if (queueAvailable && enableQueue) { queue.process(128, handler); + queueLogger.succ('Processing started'); } + + return queue; } |