config.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. package utils
  2. import (
  3. "errors"
  4. "fmt"
  5. "strconv"
  6. beeLogger "github.com/beego/bee/v2/logger"
  7. "github.com/beego/beego/v2/server/web"
  8. "github.com/qiniu/qmgo"
  9. "github.com/spf13/viper"
  10. )
  11. var (
  12. RunMode string //运行模式
  13. MYSQL_URL string //数据库连接
  14. MYSQL_URL_RDDP string //数据库连接
  15. MYSQL_URL_EDB string
  16. MYSQL_URL_DATA string
  17. MYSQL_URL_GL string
  18. MYSQL_LOG_URL string
  19. MYSQL_WEEKLY_URL string //用户主库
  20. MYSQL_AI_URL string //ETA-AI 数据库
  21. MgoUrlData string // mongodb数据库连接配置
  22. DBDRIVER_NAME string //数据库驱动
  23. REDIS_CACHE string //缓存地址
  24. //Rc *cache.Cache //redis缓存
  25. Re error //redis错误
  26. Rc RedisClient //redis缓存
  27. MgoDataCli *qmgo.Client // mongodb客户端连接
  28. MgoDataDbName string // mongodb指标数据的库名
  29. )
  30. // binlog
  31. var (
  32. MYSQL_DATA_BINLOG_URL string // 数据指标库binlog地址
  33. MYSQL_DATA_BINLOG_USER string // 数据指标库binlog用户名
  34. MYSQL_DATA_BINLOG_PWD string // 数据指标库binlog密码
  35. MYSQL_DATA_BINLOG_DB string // 数据指标库binlog位置
  36. MYSQL_DATA_BINLOG_SERVER_ID string // 数据指标库binlog server_id
  37. MYSQL_DATA_BINLOG_DB_EDB string // 数据手工指标binlog位置
  38. MYSQL_DATA_BINLOG_DB_GL string // 数据钢联binlog位置
  39. )
  40. // 基础配置
  41. var (
  42. STATIC_DIR string
  43. DesKey string // 接口返回加密KEY
  44. APPNAME string //项目中文名称
  45. EmailSendToUsers string // 邮件提醒人员
  46. JhGnAppKey string // 聚合短信,国内AppKey
  47. JhGjAppKey string // 聚合短信,国际AppKey
  48. ResourceProxyUrl string // 代理资源地址
  49. RESOURCE_DIR string
  50. )
  51. // ES配置
  52. var (
  53. ES_URL string // ES服务器地址
  54. ES_USERNAME string // ES账号
  55. ES_PASSWORD string // ES密码
  56. )
  57. // 公共api内部服务调用
  58. var (
  59. // EDB_LIB_URL 公共指标库
  60. EDB_LIB_URL string
  61. APP_EDB_LIB_NAME_EN string
  62. EDB_LIB_Md5_KEY string
  63. // PublicChartHost 公共图库的host
  64. PublicChartHost string
  65. // MySteelPostUrl 钢联化工的服务地址
  66. MySteelPostUrl string
  67. // SendWxTemplateMsgUrl 模板消息推送
  68. SendWxTemplateMsgUrl string
  69. // SendTemplateMsgAuthorization 模板推送秘钥
  70. SendTemplateMsgAuthorization string
  71. // HandleVideoDecibelUrl 处理音频分贝的url
  72. HandleVideoDecibelUrl string
  73. // Ppt2ImageUrl ppt转图片服务的地址
  74. Ppt2ImageUrl string
  75. // HongzeOpenApiHost 开放openapi的地址
  76. HongzeOpenApiHost string
  77. // EnglishShareUrl 英文研报群发邮件分享地址
  78. EnglishShareUrl string
  79. // EnPolicyReportUrl 英文策略报告
  80. EnPolicyReportUrl string
  81. // GoogleTranslateUrl 谷歌翻译服务
  82. GoogleTranslateUrl string
  83. // AlarmMsgUrl 报警服务地址
  84. AlarmMsgUrl string
  85. // ChatUrl chatGPT服务地址
  86. ChatUrl string
  87. EtaBridgeUrl string // 桥接服务地址
  88. EtaBridgeAppNameEn string // 桥接服务英文名称-鉴权用
  89. EtaBridgeMd5Key string // 桥接服务Md5密钥-鉴权用
  90. EtaBridgeDesKey string // 桥接服务Des密钥-解密数据用
  91. EtaBridgeLoginUrl string // 第三方登录鉴权接口地址
  92. EtaBridgeLogoutUrl string // 第三方登出接口地址
  93. ETAMiniBridgeUrl string // 桥接服务地址
  94. ETA_MINI_APPID string // 桥接服务-鉴权用
  95. ETA_MINI_APP_SECRET string // 桥接服务-鉴权用
  96. )
  97. // 微信配置信息
  98. var (
  99. WxId string //微信原始ID
  100. WxAppId string // 公众号appid
  101. WxAppSecret string // 公众号秘钥
  102. TemplateIdByProduct string //产品运行报告通知-模板ID
  103. WxYbAppId string // 研报小程序appid
  104. WxYbId string // 研报小程序微信原始ID
  105. WxYbAppSecret string // 研报小程序秘钥
  106. WxYbPlatform int //弘则研报来源
  107. )
  108. // ES索引配置
  109. var (
  110. DATA_INDEX_NAME string //数据指标库索引
  111. CHART_INDEX_NAME string //研究图库索引
  112. EsReportIndexName string //研报ES索引
  113. EsEnglishReportIndexName string //英文研报ES索引
  114. MY_CHART_INDEX_NAME string //研究图库(MY ETA)索引
  115. EsSemanticAnalysisDocIndexName string //ES语义分析文档索引名
  116. SmartReportIndexName string //智能研报ES索引
  117. EsExcelIndexName string // 表格ES索引名称
  118. EsDataSourceIndexName string // 数据源ES索引名称
  119. )
  120. var (
  121. XfHostUrl string // 科大讯飞--语音合成
  122. )
  123. // 对象存储客户端
  124. var (
  125. ObjectStorageClient string // 目前有oss minio,默认oss
  126. PptUpdateApi string //ppt 通过后端接口的方式上传
  127. )
  128. // 阿里云配置
  129. var (
  130. Bucketname string
  131. Endpoint string
  132. Imghost string
  133. UploadDir string
  134. Upload_Audio_Dir string
  135. AccessKeyId string
  136. AccessKeySecret string
  137. )
  138. // 阿里云oss前端上传用
  139. var (
  140. AliStsScheme string
  141. RegionId string
  142. RoleArn string
  143. RoleSessionName string
  144. RAMAccessKeyId string
  145. RAMAccessKeySecret string
  146. STSTokenCacheKey string
  147. )
  148. // 阿里云邮箱配置
  149. var (
  150. AliyunEmailAccountName string
  151. AliyunEmailAccessKeyId string
  152. AliyunEmailAccessKeySecret string
  153. AliyunEmailReplyAddress string
  154. AliyunEmailReplyAddressAlias string
  155. )
  156. // 腾讯云邮箱配置
  157. var (
  158. TencentSDKSecretId string // 腾讯云主账号SecretId
  159. TencentSDKSecretKey string // 腾讯云主账号SecretKey
  160. TencentEmailFromEmailAddress string // 腾讯云邮件发信地址
  161. TencentEmailTemplateID uint64 // 云邮件模板ID
  162. )
  163. // LibreOfficePath LibreOfficePath的地址
  164. var LibreOfficePath string
  165. // CrmEtaServerUrl CRM-ETA服务地址
  166. var (
  167. CrmEtaServerUrl string
  168. CrmEtaServerDes3Key string
  169. )
  170. // eta_forum_hub ETA社区桥接服务地址
  171. var (
  172. ETA_FORUM_HUB_URL string
  173. ETA_FORUM_HUB_NAME_EN string
  174. ETA_FORUM_HUB_MD5_KEY string
  175. )
  176. // BusinessCode 商家编码
  177. var BusinessCode string
  178. // 日志配置
  179. var (
  180. LogPath string //调用过程中的日志存放地址
  181. LogFile string
  182. LogDataPath string //调用过程中图表相关的日志存放地址
  183. LogDataFile string
  184. BinLogPath string //数据库相关的日志存放地址
  185. BinLogFile string
  186. ApiLogPath string //接口请求地址和接口返回值日志存放地址
  187. ApiLogFile string
  188. LogMaxDays int //日志最大保留天数
  189. )
  190. // MinIo配置
  191. var (
  192. MinIoBucketname string
  193. MinIoEndpoint string
  194. MinIoBackEndpoint string
  195. MinIoImghost string
  196. MinIoUploadDir string
  197. MinIoUpload_Audio_Dir string
  198. MinIoAccessKeyId string
  199. MinIoAccessKeySecret string
  200. MinIoUseSSL string
  201. MinIoPort string
  202. MinIoRegion string
  203. MinIoFileDownloadHost string
  204. )
  205. // PythonUrlReport2Img 生成长图服务地址
  206. var PythonUrlReport2Img string
  207. // ETA-AI服务
  208. var EtaAiUrl string
  209. var (
  210. EtaAppid string
  211. EtaSecret string
  212. )
  213. // S3配置
  214. var (
  215. S3Endpoint string
  216. S3BackEndpoint string
  217. S3BucketName string
  218. S3UploadDir string
  219. S3AccessKeyId string
  220. S3AccessKeySecret string
  221. S3Host string
  222. S3Region string
  223. S3ForceStyle string
  224. S3EndpointPort string
  225. S3Protocol string
  226. S3DisableSSL string
  227. S3OpenAcl string
  228. )
  229. // chrome配置
  230. var (
  231. ChromePath string // chrome浏览器地址
  232. )
  233. var (
  234. ErrMsgConfigFile string
  235. )
  236. var (
  237. ViperConfig *viper.Viper
  238. )
  239. var (
  240. UseMongo bool // 是否使用mongo
  241. )
  242. func init() {
  243. tmpRunMode, err := web.AppConfig.String("run_mode")
  244. if err != nil {
  245. panic(any("配置文件读取run_mode错误 " + err.Error()))
  246. }
  247. RunMode = tmpRunMode
  248. fmt.Println("RunMode:", RunMode)
  249. if RunMode == "" {
  250. localIp, err := GetLocalIP()
  251. fmt.Println("localIp:", localIp)
  252. if localIp == "10.0.0.123" {
  253. RunMode = "debug"
  254. } else {
  255. RunMode = "release"
  256. }
  257. fmt.Println("RunMode:", RunMode)
  258. configPath := `/home/code/config/eta_api/conf/app.conf`
  259. fmt.Println("configPath:", configPath)
  260. err = web.LoadAppConfig("ini", configPath)
  261. if err != nil {
  262. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  263. }
  264. }
  265. config, err := web.AppConfig.GetSection(RunMode)
  266. if err != nil {
  267. panic(any("配置文件读取错误 " + err.Error()))
  268. }
  269. beeLogger.Log.Info(RunMode + " 模式")
  270. MYSQL_URL = config["mysql_url"]
  271. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  272. MYSQL_URL_EDB = config["mysql_url_edb"]
  273. MYSQL_URL_DATA = config["mysql_url_data"]
  274. MYSQL_URL_GL = config["mysql_url_gl"]
  275. MYSQL_LOG_URL = config["mysql_url_log"]
  276. // 用户主库
  277. MYSQL_WEEKLY_URL = config["mysql_url_weekly"]
  278. // 用户主库
  279. MYSQL_WEEKLY_URL = config["mysql_url_weekly"]
  280. //ETA-AI
  281. MYSQL_AI_URL = config["mysql_url_ai"]
  282. DBDRIVER_NAME = config["db_driver_name"]
  283. if DBDRIVER_NAME == "" {
  284. DBDRIVER_NAME = "mysql"
  285. }
  286. // binlog配置
  287. {
  288. MYSQL_DATA_BINLOG_URL = config["mysql_data_binlog_url"]
  289. MYSQL_DATA_BINLOG_USER = config["mysql_data_binlog_user"]
  290. MYSQL_DATA_BINLOG_PWD = config["mysql_data_binlog_pwd"]
  291. MYSQL_DATA_BINLOG_DB = config["mysql_data_binlog_db"]
  292. MYSQL_DATA_BINLOG_SERVER_ID = config["mysql_data_binlog_server_id"]
  293. MYSQL_DATA_BINLOG_DB_EDB = config["mysql_data_binlog_db_edb"]
  294. MYSQL_DATA_BINLOG_DB_GL = config["mysql_data_binlog_db_gl"]
  295. }
  296. // mongodb数据库连接配置
  297. MgoUrlData = config["mgo_url_data"]
  298. REDIS_CACHE = config["beego_cache"]
  299. if len(REDIS_CACHE) <= 0 {
  300. panic(any("redis链接参数没有配置"))
  301. }
  302. //Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  303. //if Re != nil {
  304. // fmt.Println("redis链接异常:", Re)
  305. // panic(any(Re))
  306. //}
  307. // 初始化缓存
  308. redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
  309. if err != nil {
  310. fmt.Println("redis链接异常:", err)
  311. panic(any(Re))
  312. }
  313. Rc = redisClient
  314. // 项目中文名称
  315. appNameCn, err := web.AppConfig.String("app_name_cn")
  316. if err != nil {
  317. panic(any("配置文件读取app_name_cn错误 " + err.Error()))
  318. }
  319. APPNAME = appNameCn
  320. // 初始化内部服务配置
  321. // 接口返回加密KEY
  322. DesKey = config["des_key"]
  323. // 邮件提醒人员
  324. EmailSendToUsers = config["email_send_to_users"]
  325. // 聚合短信,国内AppKey
  326. JhGnAppKey = config["jh_gn_app_key"]
  327. JhGjAppKey = config["jh_gj_app_key"]
  328. // ppt 转图片服务地址
  329. Ppt2ImageUrl = config["ppt2_image_url"]
  330. // 静态文件目录
  331. STATIC_DIR = config["static_dir"]
  332. // 代理资源地址
  333. ResourceProxyUrl = config["resource_proxy_url"]
  334. RESOURCE_DIR = config["resource_dir"]
  335. if RESOURCE_DIR == "" {
  336. RESOURCE_DIR = "eta/"
  337. }
  338. // 系统内部服务地址
  339. {
  340. // 公共指标库相关
  341. EDB_LIB_URL = config["edb_lib_url"]
  342. APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
  343. EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
  344. // 图表项目域名
  345. PublicChartHost = config["public_chart_host"]
  346. // 钢联化工服务地址
  347. MySteelPostUrl = config["mysteel_post_url"]
  348. // 发送微信模板消息地址
  349. SendWxTemplateMsgUrl = config["send_wx_template_msg_url"]
  350. // 发送微信模板消息地址
  351. SendTemplateMsgAuthorization = config["send_template_msg_authorization"]
  352. // 语音分贝处理的地址
  353. HandleVideoDecibelUrl = config["handle_video_decibel_url"]
  354. // 弘则open api的地址
  355. HongzeOpenApiHost = config["hongze_open_api_host"]
  356. // 英文研报分享的地址
  357. EnglishShareUrl = config["english_share_url"]
  358. // 策略报告地址
  359. EnPolicyReportUrl = config["en_policy_report_url"]
  360. // 谷歌翻译服务地址
  361. GoogleTranslateUrl = config["google_translate_url"]
  362. // 报警服务地址
  363. AlarmMsgUrl = config["alarm_msg_url"]
  364. // chatGPT服务地址
  365. ChatUrl = config["chat_url"]
  366. EtaBridgeUrl = config["eta_bridge_url"] // 桥接服务地址
  367. EtaBridgeAppNameEn = config["eta_bridge_app_name_en"] // 桥接服务英文名称-鉴权用
  368. EtaBridgeMd5Key = config["eta_bridge_md5_key"] // 桥接服务Md5密钥-鉴权用
  369. EtaBridgeDesKey = config["eta_bridge_des_key"] // 桥接服务Des密钥-解密数据用
  370. EtaBridgeLoginUrl = config["eta_bridge_login_url"] // eta桥接服务-登录接口地址
  371. EtaBridgeLogoutUrl = config["eta_bridge_logout_url"] // eta桥接服务-登出接口地址
  372. }
  373. //日志配置
  374. {
  375. LogPath = config["log_path"]
  376. LogFile = config["log_file"]
  377. LogDataPath = config["log_data_path"]
  378. LogDataFile = config["log_data_file"]
  379. BinLogPath = config["binlog_path"]
  380. BinLogFile = config["binlog_file"]
  381. ApiLogPath = config["apilog_path"]
  382. ApiLogFile = config["apilog_file"]
  383. logMaxDaysStr := config["log_max_day"]
  384. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  385. }
  386. // ES配置
  387. {
  388. ES_URL = config["es_url"]
  389. ES_USERNAME = config["es_username"]
  390. ES_PASSWORD = config["es_password"]
  391. }
  392. // 微信相关
  393. {
  394. WxAppId = config["wx_appid"]
  395. WxAppSecret = config["wx_app_secret"]
  396. WxId = config["wx_id"]
  397. //模板消息
  398. TemplateIdByProduct = config["template_id_by_product"]
  399. WxYbAppId = config["wx_yb_appid"] //弘则研报小程序
  400. WxYbId = config["wx_yb_id"] // 研报小程序微信原始ID
  401. WxYbAppSecret = config["wx_yb_app_secret"] // 研报小程序秘钥
  402. wxYbPlatformStr := config["wx_yb_platform"]
  403. if wxYbPlatformStr != `` {
  404. WxYbPlatform, err = strconv.Atoi(wxYbPlatformStr) //弘则研报来源
  405. if err != nil {
  406. panic(any("配置文件读取wx_yb_platform错误 " + err.Error()))
  407. }
  408. }
  409. }
  410. // 对象存储客户端
  411. ObjectStorageClient = config["object_storage_client"]
  412. // ppt上传是否走后端
  413. PptUpdateApi = config["ppt_update_api"]
  414. // OSS相关
  415. {
  416. Endpoint = config["endpoint"]
  417. Bucketname = config["bucket_name"]
  418. Imghost = config["img_host"]
  419. UploadDir = config["upload_dir"]
  420. Upload_Audio_Dir = config["upload_audio_dir"]
  421. AccessKeyId = config["access_key_id"]
  422. AccessKeySecret = config["access_key_secret"]
  423. }
  424. // OSS相关(前端使用)
  425. {
  426. AliStsScheme = config["ali_sts_scheme"]
  427. RegionId = config["region_id"]
  428. RoleArn = config["role_arn"]
  429. RoleSessionName = config["role_session_name"]
  430. RAMAccessKeyId = config["ram_access_key_id"]
  431. RAMAccessKeySecret = config["ram_access_key_secret"]
  432. STSTokenCacheKey = config["sts_token_cache_key"]
  433. }
  434. // 阿里云邮箱配置
  435. {
  436. AliyunEmailAccountName = config["aliyun_email_account_name"]
  437. AliyunEmailAccessKeyId = config["aliyun_email_access_key_id"]
  438. AliyunEmailAccessKeySecret = config["aliyun_email_access_key_secret"]
  439. AliyunEmailReplyAddress = config["aliyun_email_reply_address"]
  440. AliyunEmailReplyAddressAlias = config["aliyun_email_reply_address_alias"]
  441. }
  442. // 腾讯云邮箱配置
  443. {
  444. TencentSDKSecretId = config["tencent_sdk_secret_id"] // 腾讯云主账号SecretId
  445. TencentSDKSecretKey = config["tencent_sdk_secret_key"] // 腾讯云主账号SecretKey
  446. TencentEmailFromEmailAddress = config["tencent_email_from_email_address"] // 腾讯云邮件发信地址
  447. tencentEmailTemplateIDtr := config["tencent_email_template_id"]
  448. if tencentEmailTemplateIDtr != `` {
  449. tmpTencentEmailTemplateID, err := strconv.Atoi(tencentEmailTemplateIDtr) //弘则研报来源
  450. if err != nil {
  451. panic(any("配置文件读取tencent_email_template_id错误 " + err.Error()))
  452. }
  453. TencentEmailTemplateID = uint64(tmpTencentEmailTemplateID)
  454. }
  455. }
  456. // 科大讯飞
  457. {
  458. //XfAPPID = config["xf_appid"]
  459. //XfAPIKey = config["xf_api_key"]
  460. //XfAPISecret = config["xf_api_secret"]
  461. XfHostUrl = config["xf_host_url"]
  462. //XfOrigin = config["xf_origin"]
  463. //XfVcn = config["xf_vcn"]
  464. }
  465. // ES 索引
  466. {
  467. DATA_INDEX_NAME = config["data_index_name"]
  468. CHART_INDEX_NAME = config["chart_index_name"]
  469. MY_CHART_INDEX_NAME = config["my_chart_index_name"]
  470. EsReportIndexName = config["es_report_index_name"]
  471. EsEnglishReportIndexName = config["es_english_report_index_name"]
  472. EsSemanticAnalysisDocIndexName = config["es_semantic_analysis_doc_index_name"]
  473. SmartReportIndexName = config["es_smart_report_index_name"]
  474. }
  475. CrmEtaServerUrl = config["crm_eta_server_url"]
  476. CrmEtaServerDes3Key = config["crm_eta_server_des3_key"]
  477. LibreOfficePath = config["libre_office_path"]
  478. // eta_forum_hub ETA社区桥接服务地址
  479. {
  480. ETA_FORUM_HUB_URL = config["eta_forum_hub_url"]
  481. ETA_FORUM_HUB_NAME_EN = config["eta_forum_hub_name_en"]
  482. ETA_FORUM_HUB_MD5_KEY = config["eta_forum_hub_md5_key"]
  483. }
  484. // 商家编码
  485. BusinessCode = config["business_code"]
  486. // eta_mini_bridge 小程序桥接服务地址
  487. {
  488. ETAMiniBridgeUrl = config["eta_mini_bridge_url"]
  489. ETA_MINI_APPID = config["eta_mini_bridge_appid"] // 桥接服务-鉴权用
  490. ETA_MINI_APP_SECRET = config["eta_mini_bridge_secret"] // 桥接服务-鉴权用
  491. }
  492. // MinIo相关
  493. {
  494. MinIoEndpoint = config["minio_endpoint"]
  495. MinIoBackEndpoint = config["minio_back_endpoint"]
  496. MinIoBucketname = config["minio_bucket_name"]
  497. MinIoImghost = config["minio_img_host"]
  498. MinIoUploadDir = config["minio_upload_dir"]
  499. MinIoUpload_Audio_Dir = config["minio_upload_audio_dir"]
  500. MinIoAccessKeyId = config["minio_access_key_id"]
  501. MinIoAccessKeySecret = config["minio_access_key_secret"]
  502. MinIoUseSSL = config["minio_use_ssl"]
  503. MinIoPort = config["minio_port"]
  504. MinIoRegion = config["minio_region"]
  505. MinIoFileDownloadHost = config["minio_file_download_host"]
  506. }
  507. // S3-OSS相关
  508. {
  509. S3Endpoint = config["s3_endpoint"]
  510. S3BackEndpoint = config["s3_back_endpoint"]
  511. S3BucketName = config["s3_bucket_name"]
  512. S3Host = config["s3_host"]
  513. S3AccessKeyId = config["s3_access_key_id"]
  514. S3AccessKeySecret = config["s3_access_key_secret"]
  515. S3UploadDir = config["s3_upload_dir"]
  516. S3Region = config["s3_region"]
  517. S3ForceStyle = config["s3_force_style"]
  518. S3EndpointPort = config["s3_endpoint_port"]
  519. S3Protocol = config["s3_protocol"]
  520. S3DisableSSL = config["s3_disable_ssl"]
  521. S3OpenAcl = config["s3_open_acl"]
  522. }
  523. // 生成长图服务地址
  524. PythonUrlReport2Img = config["python_url_report2img"]
  525. EtaAiUrl = config["eta_ai_url"]
  526. EtaAppid = config["eta_appid"]
  527. EtaSecret = config["eta_secret"]
  528. // chrome配置
  529. ChromePath = config["chrome_path"]
  530. // 初始化ES
  531. initEs()
  532. ErrMsgConfigFile = config["err_msg_config_file"]
  533. if ErrMsgConfigFile != "" {
  534. viper.SetConfigFile(ErrMsgConfigFile)
  535. err = viper.ReadInConfig()
  536. if err != nil {
  537. if _, ok := err.(viper.ConfigFileNotFoundError); ok {
  538. fmt.Println(errors.New("config file not found"))
  539. panic(any("config file not found"))
  540. } else {
  541. fmt.Println(errors.New("config file was found but another error was produced err:" + err.Error()))
  542. panic(any("config file was found but another error was produced err:" + err.Error()))
  543. }
  544. return
  545. }
  546. ViperConfig = viper.GetViper()
  547. }
  548. }