附近小店
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

54 rindas
912 B

  1. package cfg
  2. import (
  3. "flag"
  4. "io/ioutil"
  5. "gopkg.in/yaml.v2"
  6. mc "applet/app/utils/cache/cache"
  7. "applet/app/utils/logx"
  8. )
  9. func InitTaskCfg() {
  10. path := flag.String("c", "etc/task.yml", "config file")
  11. flag.Parse()
  12. var (
  13. c []byte
  14. err error
  15. conf *Config
  16. )
  17. if c, err = ioutil.ReadFile(*path); err != nil {
  18. panic(err)
  19. }
  20. if err = yaml.Unmarshal(c, &conf); err != nil {
  21. panic(err)
  22. }
  23. Prd = conf.Prd
  24. Debug = conf.Debug
  25. DB = &conf.DB
  26. MQ = &conf.MQ
  27. ES = &conf.ES
  28. Log = &conf.Log
  29. Admin = &conf.Admin
  30. RedisAddr = conf.RedisAddr
  31. RedisAddrSecond = &conf.RedisAddrSecond
  32. Local = conf.Local
  33. AppComm = &conf.AppComm
  34. Zhimeng = &conf.Zhimeng
  35. Supply = &conf.Supply
  36. ZhiosOpen = &conf.ZhiosOpen
  37. ZhimengDB = &conf.ZhimengDB
  38. }
  39. var MemCache mc.Cache
  40. func InitMemCache() {
  41. var err error
  42. MemCache, err = mc.NewCache("memory", `{"interval":60}`)
  43. if err != nil {
  44. logx.Fatal(err.Error())
  45. }
  46. }