数据采集
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.
 
 
 
 
 
 

45 line
712 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. ZhimengDB = &conf.ZhimengDB
  27. Log = &conf.Log
  28. RedisAddr = conf.RedisAddr
  29. ES = &conf.ES
  30. }
  31. var MemCache mc.Cache
  32. func InitMemCache() {
  33. var err error
  34. MemCache, err = mc.NewCache("memory", `{"interval":60}`)
  35. if err != nil {
  36. logx.Fatal(err.Error())
  37. }
  38. }