123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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
- )
- var (
- Bucketname string
- Endpoint string
- Imghost string
- UploadDir string
- Upload_Audio_Dir string
- AccessKeyId string
- AccessKeySecret string
- )
- var (
- AliStsScheme string
- RegionId string
- RoleArn string
- RoleSessionName string
- RAMAccessKeyId string
- RAMAccessKeySecret string
- STSTokenCacheKey string
- )
- var (
- STATIC_DIR string
- )
- var (
- LogPath string
- LogFile string
- ApiLogPath string
- ApiLogFile string
- BinLogPath string
- BinLogFile string
- LogMaxDays int
- )
- var DesKey string
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic(any("配置文件读取run_mode错误 " + err.Error()))
- }
- RunMode = tmpRunMode
- fmt.Println("RunMode:", RunMode)
- if RunMode == "" {
- configPath := `/home/code/config/eta_mini_crm/conf/app.conf`
- fmt.Println("configPath:", configPath)
- err = web.LoadAppConfig("ini", configPath)
- if err != nil {
- fmt.Println("web.LoadAppConfig Err:" + err.Error())
- }
- tmpRunMode, _ := web.AppConfig.String("run_mode")
- RunMode = tmpRunMode
- }
- 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链接参数没有配置"))
- }
-
- DesKey = config["des_key"]
-
- {
- Endpoint = config["endpoint"]
- Bucketname = config["bucket_name"]
- Imghost = config["img_host"]
- UploadDir = config["upload_dir"]
- Upload_Audio_Dir = config["upload_audio_dir"]
- AccessKeyId = config["access_key_id"]
- AccessKeySecret = config["access_key_secret"]
- }
-
- {
- AliStsScheme = config["ali_sts_scheme"]
- RegionId = config["region_id"]
- RoleArn = config["role_arn"]
- RoleSessionName = config["role_session_name"]
- RAMAccessKeyId = config["ram_access_key_id"]
- RAMAccessKeySecret = config["ram_access_key_secret"]
- STSTokenCacheKey = config["sts_token_cache_key"]
- }
-
- STATIC_DIR = config["static_dir"]
- if STATIC_DIR == "" {
- STATIC_DIR = "./static"
- }
-
- redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
- if err != nil {
- fmt.Println("redis链接异常:", err)
- panic(any("redis链接参数没有配置"))
- }
- Rc = redisClient
- }
|