@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user