实现基础的智能调度

This commit is contained in:
GoEdgeLab
2023-05-17 18:42:21 +08:00
parent 667628aff3
commit 3fd2925780
33 changed files with 507 additions and 127 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
timeutil "github.com/iwind/TeaGo/utils/time"
"net"
"net/http"
"strconv"
@@ -66,7 +67,7 @@ func (this *HealthCheckExecutor) Run() ([]*HealthCheckResult, error) {
var tx *dbs.Tx
for _, node := range nodes {
if !node.IsOn {
if !node.IsOn || node.IsBackupForCluster || node.IsBackupForGroup || (len(node.OfflineDay) > 0 && node.OfflineDay < timeutil.Format("Ymd")) {
continue
}
@@ -194,6 +195,15 @@ func (this *HealthCheckExecutor) runNode(healthCheckConfig *serverconfigs.Health
this.logErr("HealthCheckExecutor", err.Error())
return
}
// 触发节点动作
if !result.IsOk {
err := this.fireNodeActions(int64(result.Node.Id))
if err != nil {
this.logErr("HealthCheckExecutor", err.Error())
}
return
}
}
// 触发阈值