某个在线实例出错超过阈值时,停止向该实例分配任务

This commit is contained in:
智能大石头 2025-07-30 14:45:38 +08:00
parent 0d87aa9963
commit 978abf5c89
2 changed files with 14 additions and 5 deletions

View File

@ -195,11 +195,14 @@ public class AppService
//var online = GetOnline(app, sessionId, ip);
online.Total += ji.Total;
online.Success += ji.Success;
online.Error += ji.Error;
//online.Error += ji.Error;
online.Cost += ji.Cost;
online.Speed = ji.Speed;
online.LastKey = ji.Key;
online.SaveAsync();
if (ji.Status == JobStatus.) online.Error++;
online.Update();
}
#endregion

View File

@ -470,7 +470,7 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
SetJobError(job, task, online.UpdateIP);
// 出错时判断如果超过最大错误数,则停止作业
CheckMaxError(app, job);
CheckMaxError(app, job, online);
// 记录状态
_appService.UpdateOnline(app, task, online);
@ -565,7 +565,7 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
return err;
}
private void CheckMaxError(App app, Job job)
private void CheckMaxError(App app, Job job, AppOnline online)
{
// 出错时判断如果超过最大错误数,则停止作业
var maxError = job.MaxError <= 0 ? 100 : job.MaxError;
@ -575,7 +575,13 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
job.Enable = false;
//job.SaveAsync();
(job as IEntity).Update();
job.Update();
}
if (online.Enable && online.Error > maxError)
{
online.Enable = false;
online.Update();
}
}
#endregion