Merge pull request 'conf' (#486) from conf into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/486
This commit is contained in:
commit
8c56d41d56
|
@ -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)
|
||||||
|
|
|
@ -23,5 +23,5 @@ type ConfigSt struct {
|
||||||
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
|
||||||
SD *configcenter.ConsulServiceDiscovery `json:"sd" yaml:"sd"`
|
SD *configcenter.ConsulServiceDiscovery `json:"sd" yaml:"sd"`
|
||||||
OfflineServer *configcenter.DefaultConfig `json:"offline_server" yaml:"offline_server"`
|
OfflineServer *configcenter.OfflineServerConfig `json:"offline_server" yaml:"offline_server"` // 离线任务
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,12 @@ type ConsulServiceDiscovery struct {
|
||||||
ServiceName string `json:"service_name" yaml:"service_name"`
|
ServiceName string `json:"service_name" yaml:"service_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 离线机器配置
|
||||||
|
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 {
|
||||||
|
|
|
@ -101,7 +101,7 @@ func setServerStatusFD(status string) {
|
||||||
logger.Info("SetServerStatusFD success: %v", status)
|
logger.Info("SetServerStatusFD success: %v", status)
|
||||||
}
|
}
|
||||||
|
|
||||||
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