1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package utils
- import (
- "fmt"
- beeLogger "github.com/beego/bee/v2/logger"
- "github.com/beego/beego/v2/server/web"
- )
- // 数据库配置
- var (
- RunMode string // 运行模式
- MYSQL_URL_MASTER string // 数据库地址
- MYSQL_URL_RDDP string // 数据库地址
- REDIS_CACHE string //缓存地址
- Rc RedisClient //redis缓存
- )
- var (
- ApiLogPath string // 接口请求地址和接口返回值日志存放地址
- ApiLogFile string
- BinLogPath string // 数据库相关的日志存放地址
- BinLogFile string
- LogMaxDays int // 日志最大保留天数
- )
- var DesKey string // 接口返回加密KEY
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic(any("配置文件读取run_mode错误 " + err.Error()))
- }
- RunMode = tmpRunMode
- fmt.Println("RunMode:", RunMode)
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic(any("配置文件读取错误 " + err.Error()))
- }
- beeLogger.Log.Info(RunMode + " 模式")
- MYSQL_URL_RDDP = config["mysql_url_rddp"]
- MYSQL_URL_MASTER = config["mysql_url_master"]
- REDIS_CACHE = config["beego_cache"]
- if len(REDIS_CACHE) <= 0 {
- panic(any("redis链接参数没有配置"))
- }
- // 初始化缓存
- redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
- if err != nil {
- fmt.Println("redis链接异常:", err)
- panic(any("redis链接参数没有配置"))
- }
- Rc = redisClient
- }
|