package services import ( "fmt" "hongze/mysteel_watch/global" "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) //} filePath = strings.Replace(filePath, `"`, ``, -1) fmt.Println("开始刷新文件:", filePath) time.Sleep(1 * time.Second) if global.CONFIG.Serve.SystemType == "custom" { MysteelChemicalRefresh(filePath) } else { if global.CONFIG.Serve.Frequency != "周度" && !strings.Contains(filePath, "week") { MysteelChemicalRefresh(filePath) } else { MysteelChemicalRefresh(filePath) } } //刷新完成后,清除缓存 //global.Rc.Delete(filePath) }