init.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package init
  2. import (
  3. "app.yhyue.com/moapp/jypkg/compatible"
  4. "app.yhyue.com/moapp/jypkg/middleground"
  5. "flag"
  6. _ "github.com/go-sql-driver/mysql"
  7. "github.com/zeromicro/go-zero/core/conf"
  8. "jyBXBase/rpc/internal/config"
  9. )
  10. var configFile = flag.String("cf", "etc/bxbase.yaml", "the config file")
  11. var C config.Config
  12. var err error
  13. var dbFile = flag.String("df", "etc/db.yaml", "the db file")
  14. var DB config.Db
  15. var logFile = flag.String("lf", "etc/logs.yaml", "the logs file")
  16. var Middleground *middleground.Middleground
  17. var Compatible *compatible.Compatible
  18. func init() {
  19. //基本配置
  20. conf.MustLoad(*configFile, &C)
  21. //数据库配置
  22. conf.MustLoad(*dbFile, &DB)
  23. //初始mongodb
  24. MongoDBInit(&DB.Mongo)
  25. //初始化msyql
  26. MysqlInit(&DB.Mysql)
  27. //初始redis
  28. RedisInit(&DB.Redis)
  29. //初始es
  30. EsInit(&DB.Es)
  31. Middleground = middleground.NewMiddleground(C.Etcd.Hosts).
  32. //Middleground = middleground.NewMiddleground([]string{"192.168.3.149:2379"}).
  33. RegUserCenter(C.UserCenterKey).
  34. RegPowerCheckCenter(C.PowerCheckCenterKey).
  35. RegEntManageApplication(C.EntManageApplication)
  36. Compatible = compatible.NewCompatible(&Mgo, BaseServiceMysql, MainMysql, Middleground)
  37. }