golang 的 rabbitmq 消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init_task.go 734 B

2 years 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. Log = &conf.Log
  27. Admin = &conf.Admin
  28. RedisAddr = conf.RedisAddr
  29. Local = conf.Local
  30. AppComm = &conf.AppComm
  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. }