Improved code quality of queues/index
This commit is contained in:
parent
76dc7ffb68
commit
78e6a7d1d3
@ -1,11 +1,8 @@
|
||||
import * as Bullmq from 'bullmq';
|
||||
import { default as ProdBullmq, Job, QueueEvents, QueueScheduler } from 'bullmq';
|
||||
import cuid from 'cuid';
|
||||
import { default as ProdBullmq, QueueScheduler } from 'bullmq';
|
||||
import { dev } from '$app/env';
|
||||
import { prisma } from '$lib/database';
|
||||
|
||||
import builder from './builder';
|
||||
import logger from './logger';
|
||||
import cleanup from './cleanup';
|
||||
import proxy from './proxy';
|
||||
import ssl from './ssl';
|
||||
@ -28,7 +25,7 @@ const connectionOptions = {
|
||||
}
|
||||
};
|
||||
|
||||
const cron = async () => {
|
||||
const cron = async (): Promise<void> => {
|
||||
new QueueScheduler('proxy', connectionOptions);
|
||||
new QueueScheduler('cleanup', connectionOptions);
|
||||
new QueueScheduler('ssl', connectionOptions);
|
||||
@ -89,18 +86,6 @@ const cron = async () => {
|
||||
await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } });
|
||||
if (!dev) await queue.cleanup.add('cleanup', {}, { repeat: { every: 300000 } });
|
||||
await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } });
|
||||
|
||||
const events = {
|
||||
proxy: new QueueEvents('proxy', { ...connectionOptions }),
|
||||
ssl: new QueueEvents('ssl', { ...connectionOptions })
|
||||
};
|
||||
|
||||
events.proxy.on('completed', (data) => {
|
||||
// console.log(data)
|
||||
});
|
||||
events.ssl.on('completed', (data) => {
|
||||
// console.log(data)
|
||||
});
|
||||
};
|
||||
cron().catch((error) => {
|
||||
console.log('cron failed to start');
|
||||
@ -157,9 +142,5 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
|
||||
|
||||
const buildLogQueueName = 'log_queue';
|
||||
const buildLogQueue = new Queue(buildLogQueueName, connectionOptions);
|
||||
const buildLogWorker = new Worker(buildLogQueueName, async (job) => await logger(job), {
|
||||
concurrency: 1,
|
||||
...connectionOptions
|
||||
});
|
||||
|
||||
export { buildQueue, buildLogQueue };
|
||||
|
Loading…
x
Reference in New Issue
Block a user