From 77b493c9b065a7af7533e718f8623f810e65341a Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 26 Jul 2018 08:11:47 +0900 Subject: Use bee-queue instead of Kue --- src/queue/index.ts | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'src/queue/index.ts') diff --git a/src/queue/index.ts b/src/queue/index.ts index 53853687d7..6f82d0a8b5 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -1,52 +1,36 @@ -import { createQueue } from 'kue'; +import * as Queue from 'bee-queue'; import config from '../config'; import http from './processors/http'; import { ILocalUser } from '../models/user'; -const queue = createQueue({ +const queue = new Queue('misskey', { redis: { port: config.redis.port, host: config.redis.host, - auth: config.redis.pass - } -}); + password: config.redis.pass + }, -process.once('SIGTERM', () => { - queue.shutdown(5000, (err: any) => { - console.log('Kue shutdown: ', err || ''); - process.exit(0); - }); + removeOnSuccess: true, + removeOnFailure: true }); -export function createHttp(data: any) { - return queue - .create('http', data) - .removeOnComplete(true) - .events(false) - .attempts(8) - .backoff({ delay: 16384, type: 'exponential' }); +export function createHttpJob(data: any) { + return queue.createJob(data) + .retries(4) + .backoff('exponential', 16384) // 16s + .save(); } export function deliver(user: ILocalUser, content: any, to: any) { - createHttp({ - title: 'deliver', + createHttpJob({ type: 'deliver', user, content, to - }).save(); + }); } export default function() { - /* - 256 is the default concurrency limit of Mozilla Firefox and Google - Chromium. - a8af215e691f3a2205a3758d2d96e9d328e100ff - chromium/src.git - Git at Google - https://chromium.googlesource.com/chromium/src.git/+/a8af215e691f3a2205a3758d2d96e9d328e100ff - Network.http.max-connections - MozillaZine Knowledge Base - http://kb.mozillazine.org/Network.http.max-connections - */ - //queue.process('http', 256, http); - queue.process('http', 128, http); + queue.process(8, http); } -- cgit v1.2.3-freya