From f7f0e53d5dabd22a29e3a480c5319091f24a98bd Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 24 May 2024 02:34:31 +0800 Subject: [PATCH] by Robin at 20240524 --- app/mix/cmd_offline/main.go | 2 +- app/mix/conf/cfg.go | 2 +- library/configcenter/configcenter.go | 6 ++++++ library/httpserver/httpserver.go | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/mix/cmd_offline/main.go b/app/mix/cmd_offline/main.go index 3a5ea5f6..6ddf4ce4 100644 --- a/app/mix/cmd_offline/main.go +++ b/app/mix/cmd_offline/main.go @@ -57,7 +57,7 @@ func main() { } // 初始化日志 - logger.InitLogger(cfg.OfflineServer.Log) + logger.InitLogger(*cfg.OfflineServer.Log) // 初始化短信服务 err = sms.Init(cfg.Dysmsapi) diff --git a/app/mix/conf/cfg.go b/app/mix/conf/cfg.go index 0e976526..43cbd31c 100644 --- a/app/mix/conf/cfg.go +++ b/app/mix/conf/cfg.go @@ -22,5 +22,5 @@ type ConfigSt struct { DingTalkRobot *configcenter.DingTalkRobotConfig `json:"ding_talk_robot" yaml:"ding_talk_robot"` // 钉钉机器人 VideoModeration *configcenter.VideoModerationConfig `json:"video_moderation" yaml:"video_moderation"` // 视频审核 ElasticSearch *configcenter.ElasticSearchConfig `json:"elastic_search" yaml:"elastic_search"` // es - OfflineServer *configcenter.DefaultConfig `json:"offline_server" yaml:"offline_server"` + OfflineServer *configcenter.OfflineServerConfig `json:"offline_server" yaml:"offline_server"` // 离线任务 } diff --git a/library/configcenter/configcenter.go b/library/configcenter/configcenter.go index ae463e08..2547d57d 100644 --- a/library/configcenter/configcenter.go +++ b/library/configcenter/configcenter.go @@ -173,6 +173,12 @@ type ElasticSearchConfig struct { Sniff bool `json:"sniff" yaml:"sniff"` // sniffer } +// 离线机器配置 +type OfflineServerConfig struct { + Log *LoggerConfig `json:"log" yaml:"log"` // 日志配置 + App *AppConfig `json:"app" yaml:"app"` // 服务配置 +} + func LoadConfig(configFilePath string, cfg interface{}) error { cfgStr, err := ioutil.ReadFile(configFilePath) if err != nil { diff --git a/library/httpserver/httpserver.go b/library/httpserver/httpserver.go index 4381a968..15793530 100644 --- a/library/httpserver/httpserver.go +++ b/library/httpserver/httpserver.go @@ -41,7 +41,7 @@ func StartHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig) { logger.Info("Server exited") } -func StartOfflineHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig) { +func StartOfflineHttpServer(srv *http.Server, cfg *configcenter.OfflineServerConfig) { go func() { if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { logger.Fatal("listen: %v", err)