init.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package init
  2. import (
  3. "app.yhyue.com/moapp/jy_docs/rpc/partnerlib/internal/config"
  4. "app.yhyue.com/moapp/jy_docs/services/partner"
  5. jyDocsRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
  6. "flag"
  7. "github.com/zeromicro/go-zero/core/conf"
  8. )
  9. var (
  10. configFile = flag.String("c", "etc/partnerlib.yaml", "the partnerlib file")
  11. interfaceFile = flag.String("i", "etc/interface.yaml", "the interface file")
  12. crontabFile = flag.String("cron", "etc/crontab.yaml", "the crontab file")
  13. warnFile = flag.String("warn", "etc/warn.yaml", "the warn file")
  14. C config.Config
  15. I config.InterfaceInfo
  16. Cron config.CrontabInfo
  17. Warn config.Warn
  18. )
  19. func init() {
  20. conf.MustLoad(*configFile, &C)
  21. conf.MustLoad(*interfaceFile, &I)
  22. conf.MustLoad(*crontabFile, &Cron)
  23. conf.MustLoad(*warnFile, &Warn)
  24. if C.JyDocsMysqlDB.DataSourceName != "" && C.EsConfig.Addr != "" {
  25. jyDocsRpcUtil.InitDB(C.JyDocsMysqlDB.DataSourceName, C.JyDocsMysqlDB.DriverName, C.JyDocsMysqlDB.MaxOpenConn, C.JyDocsMysqlDB.MaxIdleConn)
  26. jyDocsRpcUtil.InitESV7(C.EsConfig.Addr, C.EsConfig.Pool, C.EsConfig.UserName, C.EsConfig.Password)
  27. jyDocsRpcUtil.InitRedis(C.RedisAddr)
  28. jyDocsRpcUtil.InitMongo(C.Mongo)
  29. jyDocsRpcUtil.InitOss(C.FileSystemConf)
  30. }
  31. //初始化 分类对应关系
  32. go partner.InitDocClass()
  33. }