index_queue.go 647 B

1234567891011121314151617181920212223242526272829303132
  1. package services
  2. import (
  3. "fmt"
  4. "hongze/mysteel_watch/global"
  5. "hongze/mysteel_watch/utils"
  6. "time"
  7. )
  8. // the service for log
  9. func AutoRefresh() {
  10. defer func() {
  11. if err := recover(); err != nil {
  12. fmt.Println("[AutoRefresh]", err)
  13. }
  14. }()
  15. for {
  16. global.Rc.Brpop(utils.REFRESH_INDEX, func(b []byte) {
  17. filePath := string(b)
  18. IndexHandle(filePath)
  19. })
  20. }
  21. }
  22. func IndexHandle(filePath string) {
  23. //err := UpdateComment(filePath)
  24. //if err != nil {
  25. // go alarm_msg.SendAlarmMsg(utils.APPNAME+" 指标数据未生成检测失败:"+err.Error()+";file:"+filePath, 3)
  26. //}
  27. time.Sleep(1 * time.Second)
  28. MysteelChemicalRefresh(filePath)
  29. }