|
- package cfg
-
- import (
- "flag"
- "io/ioutil"
-
- "gopkg.in/yaml.v2"
-
- mc "applet/app/utils/cache/cache"
- "applet/app/utils/logx"
- )
-
- func InitTaskCfg() {
- path := flag.String("c", "etc/task.yml", "config file")
- flag.Parse()
- var (
- c []byte
- err error
- conf *Config
- )
- if c, err = ioutil.ReadFile(*path); err != nil {
- panic(err)
- }
- if err = yaml.Unmarshal(c, &conf); err != nil {
- panic(err)
- }
- Prd = conf.Prd
- Debug = conf.Debug
- DB = &conf.DB
- MQ = &conf.MQ
- ES = &conf.ES
- Log = &conf.Log
- Admin = &conf.Admin
- RedisAddr = conf.RedisAddr
- RedisAddrSecond = &conf.RedisAddrSecond
- Local = conf.Local
- AppComm = &conf.AppComm
- Zhimeng = &conf.Zhimeng
- Supply = &conf.Supply
- ZhiosOpen = &conf.ZhiosOpen
- ZhimengDB = &conf.ZhimengDB
-
- }
-
- var MemCache mc.Cache
-
- func InitMemCache() {
- var err error
- MemCache, err = mc.NewCache("memory", `{"interval":60}`)
- if err != nil {
- logx.Fatal(err.Error())
- }
- }
|