update: 发送消息前对服务器状态进行拷贝 保证消息发送的状态指标与触发该请求的状态指标相同

This commit is contained in:
Akkia
2022-04-18 19:59:42 +08:00
parent 61630a41db
commit 1f08b579a4
4 changed files with 24 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ package singleton
import (
"bytes"
"fmt"
"github.com/jinzhu/copier"
"sync"
"github.com/robfig/cron/v3"
@@ -84,7 +85,10 @@ func CronTrigger(cr model.Cron) func() {
Type: model.TaskTypeCommand,
})
} else {
SendNotification(cr.NotificationTag, fmt.Sprintf("$%d$[任务失败] %s服务器 %s 离线,无法执行。", s.ID, cr.Name, s.Name), false)
// 保存当前服务器状态信息
curServer := model.Server{}
copier.Copy(&curServer, s)
SendNotification(cr.NotificationTag, fmt.Sprintf("[任务失败] %s服务器 %s 离线,无法执行。", cr.Name, s.Name), false, &curServer)
}
}
}