work on queue
This commit is contained in:
parent
bf2fa003b9
commit
9b8a7bdd4b
6 changed files with 488 additions and 420 deletions
|
|
@ -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'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue