summaryrefslogtreecommitdiff
path: root/src/queue/index.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-07-26 08:11:47 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-07-26 08:11:47 +0900
commit77b493c9b065a7af7533e718f8623f810e65341a (patch)
tree0830dd5f4accae60d7920417af2026830eb884e8 /src/queue/index.ts
parent:v: (diff)
downloadsharkey-77b493c9b065a7af7533e718f8623f810e65341a.tar.gz
sharkey-77b493c9b065a7af7533e718f8623f810e65341a.tar.bz2
sharkey-77b493c9b065a7af7533e718f8623f810e65341a.zip
Use bee-queue instead of Kue
Diffstat (limited to 'src/queue/index.ts')
-rw-r--r--src/queue/index.ts44
1 files changed, 14 insertions, 30 deletions
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);
}