feat: add 529 overload cooldown toggle and duration settings in admin gateway page
Move 529 overload cooldown configuration from config file to admin settings UI. Adds an enable/disable toggle and configurable cooldown duration (1-120 min) under /admin/settings gateway tab, stored as JSON in the settings table. When disabled, 529 errors are logged but accounts are no longer paused from scheduling. Falls back to config file value when DB is unreachable or settingService is nil.
This commit is contained in:
@@ -1023,11 +1023,34 @@ func parseOpenAIRateLimitResetTime(body []byte) *int64 {
|
||||
}
|
||||
|
||||
// handle529 处理529过载错误
|
||||
// 根据配置设置过载冷却时间
|
||||
// 根据配置决定是否暂停账号调度及冷却时长
|
||||
func (s *RateLimitService) handle529(ctx context.Context, account *Account) {
|
||||
cooldownMinutes := s.cfg.RateLimit.OverloadCooldownMinutes
|
||||
var settings *OverloadCooldownSettings
|
||||
if s.settingService != nil {
|
||||
var err error
|
||||
settings, err = s.settingService.GetOverloadCooldownSettings(ctx)
|
||||
if err != nil {
|
||||
slog.Warn("overload_settings_read_failed", "account_id", account.ID, "error", err)
|
||||
settings = nil
|
||||
}
|
||||
}
|
||||
// 回退到配置文件
|
||||
if settings == nil {
|
||||
cooldown := s.cfg.RateLimit.OverloadCooldownMinutes
|
||||
if cooldown <= 0 {
|
||||
cooldown = 10
|
||||
}
|
||||
settings = &OverloadCooldownSettings{Enabled: true, CooldownMinutes: cooldown}
|
||||
}
|
||||
|
||||
if !settings.Enabled {
|
||||
slog.Info("account_529_ignored", "account_id", account.ID, "reason", "overload_cooldown_disabled")
|
||||
return
|
||||
}
|
||||
|
||||
cooldownMinutes := settings.CooldownMinutes
|
||||
if cooldownMinutes <= 0 {
|
||||
cooldownMinutes = 10 // 默认10分钟
|
||||
cooldownMinutes = 10
|
||||
}
|
||||
|
||||
until := time.Now().Add(time.Duration(cooldownMinutes) * time.Minute)
|
||||
|
||||
Reference in New Issue
Block a user