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 //redis缓存
- Re error //redis错误
- )
- 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
- 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")
- }
- }
- //http://webapi.brilliantstart.cn/api/
- //http://webapi.brilliantstart.cn/swagger/
- //http://139.196.122.219:8603/swagger/
|