package utils import ( "fmt" beeLogger "github.com/beego/bee/v2/logger" "github.com/beego/beego/v2/server/web" "github.com/rdlucklib/rdluck_tools/cache" "strconv" ) var ( RunMode string //运行模式 MYSQL_URL string //数据库连接 MYSQL_WEEKLY_URL string //用户主库 REDIS_CACHE string //缓存地址 Rc *cache.Cache //redis缓存 Re error //redis错误 ) var ( STATIC_DIR string ) var ( DATA_INDEX_NAME string //数据指标库索引 ) // 日志配置 var ( LogPath string //调用过程中的日志存放地址 LogFile string BinLogPath string //数据库相关的日志存放地址 BinLogFile string ApiLogPath string //接口请求地址和接口返回值日志存放地址 ApiLogFile string LogMaxDays int //日志最大保留天数 ) func init() { tmpRunMode, err := web.AppConfig.String("run_mode") if err != nil { panic("配置文件读取run_mode错误 " + err.Error()) } RunMode = tmpRunMode fmt.Println("RunMode:", RunMode) if RunMode == "" { localIp, err := GetLocalIP() if localIp == "10.0.0.123" { RunMode = "debug" } else { RunMode = "release" } configPath := `/home/code/config/eta_data_push/conf/app.conf` err = web.LoadAppConfig("ini", configPath) if err != nil { fmt.Println("web.LoadAppConfig Err:" + err.Error()) } } config, err := web.AppConfig.GetSection(RunMode) if err != nil { panic("配置文件读取错误 " + err.Error()) } beeLogger.Log.Info(RunMode + " 模式") MYSQL_URL = config["mysql_url"] // 用户主库 MYSQL_WEEKLY_URL = config["mysql_url_weekly"] REDIS_CACHE = config["beego_cache"] if len(REDIS_CACHE) <= 0 { panic("redis链接参数没有配置") } Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存 if Re != nil { fmt.Println(Re) panic(Re) } if RunMode == "release" { } else { } //日志配置 { LogPath = config["log_path"] LogFile = config["log_file"] BinLogPath = config["binlog_path"] BinLogFile = config["binlog_file"] ApiLogPath = config["apilog_path"] ApiLogFile = config["apilog_file"] logMaxDaysStr := config["log_max_day"] LogMaxDays, _ = strconv.Atoi(logMaxDaysStr) } } //修改接口文档 //http://8.136.199.33:8300/swagger/