config.go 19 KB

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