123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- 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
- PRCPool ClientPool
- )
- var ObjectStorageClient string
- var (
- ETA_PUB_URL string
- ETA_PUB_TOKEN string
- )
- var (
- Bucketname string
- Endpoint string
- Imghost string
- UploadDir string
- AccessKeyId string
- AccessKeySecret string
- )
- var (
- MinIoBucketname string
- MinIoEndpoint string
- MinIoBackEndpoint string
- MinIoPdfhost string
- MinIoUploadDir string
- MinIoAccessKeyId string
- MinIoAccessKeySecret string
- MinIoUseSSL string
- MinIoPort string
- MinIoRegion string
- )
- var (
- AliStsScheme string
- RegionId string
- RoleArn string
- RoleSessionName string
- RAMAccessKeyId string
- RAMAccessKeySecret string
- STSTokenCacheKey string
- )
- var (
- STATIC_DIR string
- RESOURCE_DIR string
- UPLOAD_PDF_SIZE string
- UPLOAD_IMG_SIZE string
- UPLOAD_AUDIO_SIZE string
- UPLOAD_VIDEO_SIZE string
- UPLOAD_MULTI_VIDEO_SIZE string
- )
- var (
- ES_URL string
- ES_USERNAME string
- ES_PASSWORD string
- MEDIA_INDEX string
- )
- var (
- HT_WX_APP_SECRET string
- HT_WX_APPID string
- HT_MINI_APPID string
- TEMPLATE_ID_BY_PRODUCT string
- RESOURCE string
- )
- var (
- ENABLE_TASK string
- )
- var (
- MINI_REPORT_INDEX_NAME string
- )
- var (
- LogPath string
- LogFile string
- ApiLogPath string
- ApiLogFile string
- BinLogPath string
- BinLogFile string
- LogMaxDays int
- )
- var (
- SSO_URL string
- )
- 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_ht/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"]
-
- ObjectStorageClient = config["object_storage_client"]
- if ObjectStorageClient == "" {
- ObjectStorageClient = "oss"
- }
-
- {
- Endpoint = config["endpoint"]
- Bucketname = config["bucket_name"]
- Imghost = config["img_host"]
- UploadDir = config["upload_dir"]
- AccessKeyId = config["access_key_id"]
- AccessKeySecret = config["access_key_secret"]
- }
-
- {
- MinIoEndpoint = config["minio_endpoint"]
- MinIoBackEndpoint = config["minio_back_endpoint"]
- MinIoBucketname = config["minio_bucket_name"]
- MinIoPdfhost = config["minio_pdf_host"]
- MinIoUploadDir = config["minio_upload_dir"]
- MinIoAccessKeyId = config["minio_access_key_id"]
- MinIoAccessKeySecret = config["minio_access_key_secret"]
- MinIoUseSSL = config["minio_use_ssl"]
- MinIoPort = config["minio_port"]
- MinIoRegion = config["minio_region"]
- }
-
- {
- 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"]
- }
-
- {
- ETA_PUB_URL = config["eta_pub_url"]
- ETA_PUB_TOKEN = config["eta_pub_authorization"]
- }
-
- {
- ES_URL = config["es_url"]
- ES_USERNAME = config["es_username"]
- ES_PASSWORD = config["es_password"]
- }
- {
- ENABLE_TASK = config["enable_task"]
- }
-
- {
- MINI_REPORT_INDEX_NAME = config["mini_report_index_name"]
- MEDIA_INDEX = config["media_index"]
- }
- {
- HT_WX_APPID = config["ht_wx_appid"]
- HT_WX_APP_SECRET = config["ht_wx_app_secret"]
- TEMPLATE_ID_BY_PRODUCT = config["template_id_by_product"]
- HT_MINI_APPID = config["ht_mini_appid"]
- RESOURCE = config["resource"]
- }
- {
- SSO_URL = config["sso_url"]
- }
-
- initEs()
-
- STATIC_DIR = config["static_dir"]
- if STATIC_DIR == "" {
- STATIC_DIR = "./static"
- }
- RESOURCE_DIR = config["resource_dir"]
- if RESOURCE_DIR == "" {
- RESOURCE_DIR = "ht/"
- }
- UPLOAD_PDF_SIZE = config["upload_pdf_size"]
- if UPLOAD_PDF_SIZE == "" {
- UPLOAD_PDF_SIZE = "15"
- }
- UPLOAD_IMG_SIZE = config["upload_img_size"]
- if UPLOAD_IMG_SIZE == "" {
- UPLOAD_IMG_SIZE = "200"
- }
- UPLOAD_AUDIO_SIZE = config["upload_audio_size"]
- if UPLOAD_AUDIO_SIZE == "" {
- UPLOAD_AUDIO_SIZE = "100"
- }
- UPLOAD_VIDEO_SIZE = config["upload_video_size"]
- if UPLOAD_VIDEO_SIZE == "" {
- UPLOAD_VIDEO_SIZE = "1000"
- }
- UPLOAD_MULTI_VIDEO_SIZE = config["upload_multi_video_size"]
- if UPLOAD_MULTI_VIDEO_SIZE == "" {
- UPLOAD_MULTI_VIDEO_SIZE = "1"
- }
-
- redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
- if err != nil {
- fmt.Println("redis链接异常:", err)
- panic(any("redis链接参数没有配置"))
- }
- Rc = redisClient
-
- }
|