diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-02-06 13:51:02 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-02-06 13:51:02 +0900 |
| commit | e26bec6ab4e6e941a70b620879bd278b6ecf804f (patch) | |
| tree | cad74e5b2a10b64d1446c14b254ccb19adc36a33 /src/queue/index.ts | |
| parent | Merge pull request #4163 from syuilo/dependabot/npm_and_yarn/jsdom-13.2.0 (diff) | |
| download | sharkey-e26bec6ab4e6e941a70b620879bd278b6ecf804f.tar.gz sharkey-e26bec6ab4e6e941a70b620879bd278b6ecf804f.tar.bz2 sharkey-e26bec6ab4e6e941a70b620879bd278b6ecf804f.zip | |
Improve queue configuration
Resolve #4157
Resolve #4158
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; } |