manager_system.go 915 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package novicewelfare
  2. import (
  3. "encoding/json"
  4. "os"
  5. "time"
  6. "bet24.com/log"
  7. platformconfig "bet24.com/servers/micros/platformconfig/proto"
  8. )
  9. const config_key = "novicewelfare_config"
  10. // 加载配置信息
  11. func (nw *novicewelfareMgr) loadConfig() {
  12. nw.loadRedisConfig()
  13. go time.AfterFunc(5*time.Minute, nw.loadConfig)
  14. }
  15. // 加载redis配置
  16. func (nw *novicewelfareMgr) loadRedisConfig() {
  17. if data := platformconfig.GetConfig(config_key); data != "" {
  18. if err := json.Unmarshal([]byte(data), &nw.sysData); err == nil {
  19. return
  20. }
  21. return
  22. }
  23. data, err := os.ReadFile("serviceconf/novicewelfare_config.json")
  24. if err != nil {
  25. log.Release("read config failed serviceconf/novicewelfare_config.json %v", err)
  26. }
  27. if err = json.Unmarshal(data, &nw.sysData); err == nil {
  28. platformconfig.SetConfig(config_key, string(data))
  29. return
  30. }
  31. log.Release("Unmarshal config [%s] err:%v", string(data), err)
  32. }