蛋蛋星球 后台端
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 668 B

1 maand geleden
123456789101112131415161718192021222324252627282930313233343536373839404142
  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. RedisAddr = conf.RedisAddr
  28. }
  29. var MemCache mc.Cache
  30. func InitMemCache() {
  31. var err error
  32. MemCache, err = mc.NewCache("memory", `{"interval":60}`)
  33. if err != nil {
  34. logx.Fatal(err.Error())
  35. }
  36. }