by Robin at 20240524
This commit is contained in:
parent
ceb46b5f38
commit
f7f0e53d5d
|
@ -57,7 +57,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化日志
|
// 初始化日志
|
||||||
logger.InitLogger(cfg.OfflineServer.Log)
|
logger.InitLogger(*cfg.OfflineServer.Log)
|
||||||
|
|
||||||
// 初始化短信服务
|
// 初始化短信服务
|
||||||
err = sms.Init(cfg.Dysmsapi)
|
err = sms.Init(cfg.Dysmsapi)
|
||||||
|
|
|
@ -22,5 +22,5 @@ type ConfigSt struct {
|
||||||
DingTalkRobot *configcenter.DingTalkRobotConfig `json:"ding_talk_robot" yaml:"ding_talk_robot"` // 钉钉机器人
|
DingTalkRobot *configcenter.DingTalkRobotConfig `json:"ding_talk_robot" yaml:"ding_talk_robot"` // 钉钉机器人
|
||||||
VideoModeration *configcenter.VideoModerationConfig `json:"video_moderation" yaml:"video_moderation"` // 视频审核
|
VideoModeration *configcenter.VideoModerationConfig `json:"video_moderation" yaml:"video_moderation"` // 视频审核
|
||||||
ElasticSearch *configcenter.ElasticSearchConfig `json:"elastic_search" yaml:"elastic_search"` // es
|
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"` // 离线任务
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,12 @@ type ElasticSearchConfig struct {
|
||||||
Sniff bool `json:"sniff" yaml:"sniff"` // sniffer
|
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 {
|
func LoadConfig(configFilePath string, cfg interface{}) error {
|
||||||
cfgStr, err := ioutil.ReadFile(configFilePath)
|
cfgStr, err := ioutil.ReadFile(configFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -41,7 +41,7 @@ func StartHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig) {
|
||||||
logger.Info("Server exited")
|
logger.Info("Server exited")
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartOfflineHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig) {
|
func StartOfflineHttpServer(srv *http.Server, cfg *configcenter.OfflineServerConfig) {
|
||||||
go func() {
|
go func() {
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
logger.Fatal("listen: %v", err)
|
logger.Fatal("listen: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue