|
@@ -47,14 +47,6 @@ func PingStatus(ctx context.Context, nextTime time.Time) {
|
|
|
}
|
|
|
|
|
|
func PingTask(ctx context.Context, t string, wg *sync.WaitGroup, pingType int, hostPort int, serverid int) {
|
|
|
- //var ipSlice []string
|
|
|
- //ipSlice = append(ipSlice, "kdvkr-02.xyz")
|
|
|
- //ipSlice = append(ipSlice, "kdvkr-04.xyz")
|
|
|
- //pingCount, err := g.Cfg().Get(ctx, "node.pingCount")
|
|
|
- //if err != nil {
|
|
|
- // glog.Debug(ctx, err.Error())
|
|
|
- // return
|
|
|
- //}
|
|
|
pingconfig, err := service.PingConfig().Get(ctx)
|
|
|
if err != nil {
|
|
|
glog.Debug(ctx, err.Error())
|
|
@@ -137,7 +129,7 @@ func AddPingLog(ctx context.Context, pingres model.PingSt, addr string, serverid
|
|
|
|
|
|
func CheckNodeStatus(ctx context.Context, nextTime time.Time) {
|
|
|
glog.Info(ctx, nextTime)
|
|
|
- var wg sync.WaitGroup
|
|
|
+ //var wg sync.WaitGroup
|
|
|
nodeList, err := service.Node().GetNode(ctx)
|
|
|
if err != nil {
|
|
|
glog.Error(ctx, err.Error())
|
|
@@ -145,7 +137,7 @@ func CheckNodeStatus(ctx context.Context, nextTime time.Time) {
|
|
|
}
|
|
|
|
|
|
for _, target := range nodeList {
|
|
|
- wg.Add(1)
|
|
|
+
|
|
|
status, err := service.Ping().GetStatus(ctx, target.Id)
|
|
|
if err != nil {
|
|
|
glog.Error(ctx, err.Error())
|
|
@@ -156,21 +148,21 @@ func CheckNodeStatus(ctx context.Context, nextTime time.Time) {
|
|
|
switch status {
|
|
|
case consts.Down:
|
|
|
logAndCreateTaskLog(ctx, "task_url", fmt.Sprintf("当前节点%s 下线", target.Host))
|
|
|
- go processNode(ctx, target, false, &wg)
|
|
|
+ processNode(ctx, target, false)
|
|
|
case consts.Recovered:
|
|
|
logAndCreateTaskLog(ctx, "task_url", fmt.Sprintf("当前节点%s 恢复", target.Host))
|
|
|
- go processNode(ctx, target, true, &wg)
|
|
|
+ go processNode(ctx, target, true)
|
|
|
case consts.Normal:
|
|
|
logAndCreateTaskLog(ctx, "task_url", fmt.Sprintf("当前节点%s 正常无需操作", target.Host))
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- wg.Wait()
|
|
|
+ //wg.Wait()
|
|
|
}
|
|
|
|
|
|
-func processNode(ctx context.Context, target *entity.Node, isRecovery bool, wg *sync.WaitGroup) {
|
|
|
- defer wg.Done()
|
|
|
+func processNode(ctx context.Context, target *entity.Node, isRecovery bool) {
|
|
|
+ //defer wg.Done()
|
|
|
|
|
|
if isRecovery {
|
|
|
// 恢复节点执行过程
|