fix: 如果没有选择任何provider types则不进行健康检查,而不是默认全选
This commit is contained in:
parent
b2bb744916
commit
642c498544
1 changed files with 17 additions and 15 deletions
|
|
@ -1675,18 +1675,22 @@ export class ProviderPoolManager {
|
||||||
*/
|
*/
|
||||||
async performHealthChecks(isInit = false) {
|
async performHealthChecks(isInit = false) {
|
||||||
const scheduledConfig = this.globalConfig?.SCHEDULED_HEALTH_CHECK;
|
const scheduledConfig = this.globalConfig?.SCHEDULED_HEALTH_CHECK;
|
||||||
const selectedProviderTypes = scheduledConfig?.providerTypes || [];
|
const selectedProviderTypes = scheduledConfig?.providerTypes;
|
||||||
const checkAllTypes = selectedProviderTypes.length === 0;
|
|
||||||
|
|
||||||
this._log('info', 'Performing health checks on all providers...');
|
// 如果没有选择任何 provider types,不进行检查
|
||||||
|
if (!Array.isArray(selectedProviderTypes) || selectedProviderTypes.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._log('info', 'Performing health checks on selected providers...');
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
// 首先检查并恢复已到恢复时间的提供商
|
// 首先检查并恢复已到恢复时间的提供商
|
||||||
this._checkAndRecoverScheduledProviders();
|
this._checkAndRecoverScheduledProviders();
|
||||||
|
|
||||||
for (const providerType in this.providerStatus) {
|
for (const providerType in this.providerStatus) {
|
||||||
// Filter by selected provider types if specified (same logic as scheduled health check)
|
// Only check selected provider types
|
||||||
if (!checkAllTypes && !selectedProviderTypes.includes(providerType)) {
|
if (!selectedProviderTypes.includes(providerType)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1767,24 +1771,22 @@ export class ProviderPoolManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get selected provider types, if empty/undefined then check all
|
// Get selected provider types
|
||||||
let selectedProviderTypes = scheduledConfig?.providerTypes;
|
let selectedProviderTypes = scheduledConfig?.providerTypes;
|
||||||
|
|
||||||
// Validate providerTypes is an array to prevent TypeError
|
// Validate providerTypes is an array
|
||||||
if (!Array.isArray(selectedProviderTypes)) {
|
if (!Array.isArray(selectedProviderTypes) || selectedProviderTypes.length === 0) {
|
||||||
this._log('warn', '[ScheduledHealthCheck] providerTypes is not an array, treating as check all');
|
this._log('info', '[ScheduledHealthCheck] No provider types selected, skipping health check');
|
||||||
selectedProviderTypes = [];
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkAllTypes = selectedProviderTypes.length === 0;
|
|
||||||
|
|
||||||
// Count providers to be checked
|
// Count providers to be checked
|
||||||
let totalProviders = 0;
|
let totalProviders = 0;
|
||||||
let providersToCheck = [];
|
let providersToCheck = [];
|
||||||
|
|
||||||
for (const providerType in this.providerStatus) {
|
for (const providerType in this.providerStatus) {
|
||||||
// Filter by selected provider types if specified
|
// Only check selected provider types
|
||||||
if (!checkAllTypes && !selectedProviderTypes.includes(providerType)) {
|
if (!selectedProviderTypes.includes(providerType)) {
|
||||||
this._log('debug', `[ScheduledHealthCheck] Skipping provider type ${providerType}: not in selected types`);
|
this._log('debug', `[ScheduledHealthCheck] Skipping provider type ${providerType}: not in selected types`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1801,7 +1803,7 @@ export class ProviderPoolManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._log('info', `[ScheduledHealthCheck] Starting scheduled health checks: ${totalProviders} provider(s) to check (interval: ${scheduledConfig.interval}ms, types: ${checkAllTypes ? 'all' : selectedProviderTypes.join(', ')})`);
|
this._log('info', `[ScheduledHealthCheck] Starting scheduled health checks: ${totalProviders} provider(s) to check (interval: ${scheduledConfig.interval}ms, types: ${selectedProviderTypes.join(', ')})`);
|
||||||
|
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let failCount = 0;
|
let failCount = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue