index_queue.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package services
  2. import (
  3. "fmt"
  4. "hongze/mysteel_watch/global"
  5. "hongze/mysteel_watch/utils"
  6. "strings"
  7. "time"
  8. )
  9. // the service for log
  10. func AutoRefresh() {
  11. defer func() {
  12. if err := recover(); err != nil {
  13. fmt.Println("[AutoRefresh]", err)
  14. }
  15. }()
  16. for {
  17. global.Rc.Brpop(utils.REFRESH_INDEX, func(b []byte) {
  18. filePath := string(b)
  19. IndexHandle(filePath)
  20. })
  21. }
  22. }
  23. func IndexHandle(filePath string) {
  24. //err := UpdateComment(filePath)
  25. //if err != nil {
  26. // go alarm_msg.SendAlarmMsg(utils.APPNAME+" 指标数据未生成检测失败:"+err.Error()+";file:"+filePath, 3)
  27. //}
  28. filePath = strings.Replace(filePath, `"`, ``, -1)
  29. fmt.Println("开始刷新文件:", filePath)
  30. time.Sleep(1 * time.Second)
  31. if global.CONFIG.Serve.SystemType == "custom" {
  32. MysteelChemicalRefresh(filePath)
  33. } else {
  34. if global.CONFIG.Serve.Frequency != "周度" && !strings.Contains(filePath, "week") {
  35. MysteelChemicalRefresh(filePath)
  36. } else {
  37. MysteelChemicalRefresh(filePath)
  38. }
  39. }
  40. //刷新完成后,清除缓存
  41. //global.Rc.Delete(filePath)
  42. }