work on queue

This commit is contained in:
Bojan Kucera 2025-06-08 18:56:52 -04:00
parent bf2fa003b9
commit 9b8a7bdd4b
6 changed files with 488 additions and 420 deletions

View file

@ -1,5 +1,13 @@
import { ProviderConfig } from '../services/provider-registry.service';
// This will run at the same time each day as when the app started
const getEvery24HourCron = (): string => {
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
return `${minutes} ${hours} * * *`; // Every day at startup time
};
export const proxyProvider: ProviderConfig = {
name: 'proxy-service',
service: 'proxy',
@ -13,11 +21,6 @@ export const proxyProvider: ProviderConfig = {
const { proxyService } = await import('./proxy.tasks');
return await proxyService.checkProxies(payload.proxies);
},
'get-working-proxy': async (payload: { protocol?: string; country?: string; timeout?: number }) => {
const { proxyService } = await import('./proxy.tasks');
return await proxyService.getWorkingProxy();
}
},
scheduledJobs: [
@ -25,9 +28,12 @@ export const proxyProvider: ProviderConfig = {
type: 'proxy-maintenance',
operation: 'fetch-and-check',
payload: {},
cronPattern: '*/15 * * * *', // Every 15 minutes
cronPattern: getEvery24HourCron(), // Every 15 minutes
priority: 5,
immediately: true,
description: 'Fetch and validate proxy list from sources'
}
]
};