Files
firecrawl/apps/api/src/services/queue-service.ts
T

42 lines
1020 B
TypeScript
Raw Normal View History

2024-07-30 13:27:23 -04:00
import { Queue } from "bullmq";
2024-07-23 17:30:46 -03:00
import { Logger } from "../lib/logger";
2024-07-30 13:27:23 -04:00
import IORedis from "ioredis";
import { Worker } from "bullmq";
import systemMonitor from "./system-monitor";
import { v4 as uuidv4 } from "uuid";
2024-04-15 17:01:47 -04:00
2024-07-30 13:27:23 -04:00
let webScraperQueue: Queue;
export const redisConnection = new IORedis(process.env.REDIS_URL, {
maxRetriesPerRequest: null,
});
2024-04-15 17:01:47 -04:00
2024-07-30 13:27:23 -04:00
export const webScraperQueueName = "{webscraperQueue}";
2024-04-15 17:01:47 -04:00
export function getWebScraperQueue() {
if (!webScraperQueue) {
2024-07-30 13:27:23 -04:00
webScraperQueue = new Queue(
webScraperQueueName,
{
connection: redisConnection,
2024-07-18 13:19:44 -04:00
}
2024-07-30 13:27:23 -04:00
// {
// settings: {
// lockDuration: 1 * 60 * 1000, // 1 minute in milliseconds,
// lockRenewTime: 15 * 1000, // 15 seconds in milliseconds
// stalledInterval: 30 * 1000,
// maxStalledCount: 10,
// },
// defaultJobOptions:{
// attempts: 5
// }
// }
);
2024-07-23 17:30:46 -03:00
Logger.info("Web scraper queue created");
2024-04-15 17:01:47 -04:00
}
return webScraperQueue;
}
2024-07-30 13:27:23 -04:00