蛋蛋星球 后台端

init_task.go 717 B

2 months ago
1 month ago
2 months ago
2 weeks ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. IMDB = &conf.ImDB
  27. Log = &conf.Log
  28. RedisAddr = conf.RedisAddr
  29. MQ = &conf.MQ
  30. ES = &conf.ES
  31. }
  32. var MemCache mc.Cache
  33. func InitMemCache() {
  34. var err error
  35. MemCache, err = mc.NewCache("memory", `{"interval":60}`)
  36. if err != nil {
  37. logx.Fatal(err.Error())
  38. }
  39. }