trying to fix startup
This commit is contained in:
parent
00b21a57d7
commit
32d0eaac2d
7 changed files with 107 additions and 25 deletions
|
|
@ -116,17 +116,20 @@ async function initializeSharedResources() {
|
|||
enableMetrics: true
|
||||
});
|
||||
|
||||
// Always initialize httpClient and concurrencyLimit first
|
||||
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
||||
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
||||
|
||||
// Try to connect to cache, but don't block initialization if it fails
|
||||
try {
|
||||
// Use longer timeout for cache connection
|
||||
await cache.waitForReady(30000); // 30 seconds
|
||||
logger.info('Cache connection established');
|
||||
} catch (error) {
|
||||
logger.error('Cache connection failed, continuing with degraded functionality:', error);
|
||||
logger.warn('Cache connection failed, continuing with degraded functionality:', {error});
|
||||
// Don't throw - allow the service to continue with cache fallbacks
|
||||
}
|
||||
|
||||
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
||||
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
||||
logger.info('Proxy tasks initialized');
|
||||
}
|
||||
}
|
||||
|
|
@ -172,6 +175,19 @@ export async function fetchProxiesFromSources(): Promise<ProxyInfo[]> {
|
|||
await initializeSharedResources();
|
||||
await resetProxyStats();
|
||||
|
||||
// Ensure concurrencyLimit is available before using it
|
||||
if (!concurrencyLimit) {
|
||||
logger.error('concurrencyLimit not initialized, using sequential processing');
|
||||
const result = [];
|
||||
for (const source of PROXY_CONFIG.PROXY_SOURCES) {
|
||||
const proxies = await fetchProxiesFromSource(source);
|
||||
result.push(...proxies);
|
||||
}
|
||||
let allProxies: ProxyInfo[] = result;
|
||||
allProxies = removeDuplicateProxies(allProxies);
|
||||
return allProxies;
|
||||
}
|
||||
|
||||
const sources = PROXY_CONFIG.PROXY_SOURCES.map(source =>
|
||||
concurrencyLimit(() => fetchProxiesFromSource(source))
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue