12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package utils
- import (
- "fmt"
- "github.com/beego/beego/v2/core/logs"
- "github.com/beego/beego/v2/server/web"
- "rdluck_tools/cache"
- "rdluck_tools/log"
- )
- var (
- RunMode string
- MYSQL_URL string
- MYSQL_URL_RDDP string
- REDIS_CACHE string
- Rc *cache.Cache
- Re error
- )
- var ApiLog *log.Log
- var (
- Bucketname string = "hongze"
- Endpoint string
- Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
- Upload_dir string = "static/images/"
- Upload_Audio_Dir string = "static/audio/"
- AccessKeyId string = "LTAIFMZYQhS2BTvW"
- AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
- )
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic("配置文件读取run_mode错误 " + err.Error())
- }
- RunMode = tmpRunMode
- fmt.Println(RunMode, "模式")
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic("配置文件读取错误 " + err.Error())
- }
- logs.Info(RunMode + " 模式")
- MYSQL_URL = config["mysql_url"]
- MYSQL_URL_RDDP = config["mysql_url_rddp"]
-
- 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" {
- logDir := `/data/rdlucklog/hongze_open_api`
- ApiLog = log.Init("20060102.api", logDir)
- } else {
- ApiLog = log.Init("20060102.api")
- }
- }
|