mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-29 17:26:35 +08:00
提供手动控制节点上下线的接口
This commit is contained in:
@@ -94,6 +94,7 @@ func (this *DNSTaskExecutor) Loop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 修改服务相关记录
|
||||
func (this *DNSTaskExecutor) doServer(taskId int64, serverId int64) error {
|
||||
var tx *dbs.Tx
|
||||
|
||||
@@ -208,6 +209,7 @@ func (this *DNSTaskExecutor) doServer(taskId int64, serverId int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 修改节点相关记录
|
||||
func (this *DNSTaskExecutor) doNode(taskId int64, nodeId int64) error {
|
||||
isOk := false
|
||||
defer func() {
|
||||
@@ -245,6 +247,7 @@ func (this *DNSTaskExecutor) doNode(taskId int64, nodeId int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 修改集群相关记录
|
||||
func (this *DNSTaskExecutor) doCluster(taskId int64, clusterId int64) error {
|
||||
isOk := false
|
||||
defer func() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models/dns"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
@@ -131,16 +130,10 @@ func (this *HealthCheckExecutor) Run() ([]*HealthCheckResult, error) {
|
||||
|
||||
// 修改节点状态
|
||||
if healthCheckConfig.AutoDown {
|
||||
isChanged, err := models.SharedNodeDAO.UpdateNodeUp(nil, int64(result.Node.Id), result.IsOk, healthCheckConfig.CountUp, healthCheckConfig.CountDown)
|
||||
isChanged, err := models.SharedNodeDAO.UpdateNodeUpCount(nil, int64(result.Node.Id), result.IsOk, healthCheckConfig.CountUp, healthCheckConfig.CountDown)
|
||||
if err != nil {
|
||||
logs.Println("[HEALTH_CHECK]" + err.Error())
|
||||
} else if isChanged {
|
||||
// 通知DNS更新
|
||||
err = dns.SharedDNSTaskDAO.CreateNodeTask(nil, int64(result.Node.Id), dns.DNSTaskTypeNodeChange)
|
||||
if err != nil {
|
||||
logs.Println("[HEALTH_CHECK]" + err.Error())
|
||||
}
|
||||
|
||||
// 通知恢复或下线
|
||||
if result.IsOk {
|
||||
err = models.NewMessageDAO().CreateNodeMessage(nil, this.clusterId, int64(result.Node.Id), models.MessageTypeHealthCheckNodeUp, models.MessageLevelSuccess, "健康检查成功,节点\""+result.Node.Name+"\"已恢复上线", nil)
|
||||
|
||||
Reference in New Issue
Block a user