123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package services
- import (
- "fmt"
- "hongze/mysteel_watch/global"
- "hongze/mysteel_watch/services/alarm_msg"
- "hongze/mysteel_watch/utils"
- "strings"
- "time"
- )
- // the service for log
- func AutoRefresh() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[AutoRefresh]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.REFRESH_INDEX, func(b []byte) {
- filePath := string(b)
- IndexHandle(filePath)
- })
- }
- }
- func IndexHandle(filePath string) {
- err := UpdateComment(filePath)
- if err != nil {
- go alarm_msg.SendAlarmMsg(utils.APPNAME+" 指标数据未生成检测失败:"+err.Error()+";file:"+filePath, 3)
- }
- time.Sleep(1 * time.Second)
- MysteelChemicalRefresh(filePath)
- indexCodeArr := strings.Split(filePath, "_")
- if len(indexCodeArr) > 1 {
- indexCode := indexCodeArr[0]
- key := utils.REFRESH_INDEX_CODE + indexCode
- if global.Re == nil && global.Rc != nil {
- global.Rc.Delete(key)
- }
- }
- }
|