mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 20:40:25 +08:00
服务分模块加载,防止某个模块加载失败时相互受影响
This commit is contained in:
@@ -100,10 +100,12 @@ func (this *NodeConfig) Init() (err error, serverErrors []*ServerError) {
|
||||
|
||||
// servers
|
||||
for _, server := range this.Servers {
|
||||
err = server.Init()
|
||||
if err != nil {
|
||||
errs := server.Init()
|
||||
if len(errs) > 0 {
|
||||
// 这里不返回错误,而是继续往下,防止单个服务错误而影响其他服务
|
||||
serverErrors = append(serverErrors, NewServerError(server.Id, "server '"+strconv.FormatInt(server.Id, 10)+"' init failed: "+err.Error()))
|
||||
for _, serverErr := range errs {
|
||||
serverErrors = append(serverErrors, NewServerError(server.Id, "server '"+strconv.FormatInt(server.Id, 10)+"' init failed: "+serverErr.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func NewServerConfig() *ServerConfig {
|
||||
return &ServerConfig{}
|
||||
}
|
||||
|
||||
func (this *ServerConfig) Init() error {
|
||||
func (this *ServerConfig) Init() (results []error) {
|
||||
// 分解Group
|
||||
if this.Group != nil && this.Group.IsOn {
|
||||
// reverse proxy
|
||||
@@ -166,63 +166,63 @@ func (this *ServerConfig) Init() error {
|
||||
if this.HTTP != nil {
|
||||
err := this.HTTP.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.HTTPS != nil {
|
||||
err := this.HTTPS.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.TCP != nil {
|
||||
err := this.TCP.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.TLS != nil {
|
||||
err := this.TLS.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.Unix != nil {
|
||||
err := this.Unix.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.UDP != nil {
|
||||
err := this.UDP.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.ReverseProxyRef != nil {
|
||||
err := this.ReverseProxyRef.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.ReverseProxy != nil {
|
||||
err := this.ReverseProxy.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
if this.Web != nil {
|
||||
err := this.Web.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ func (this *ServerConfig) Init() error {
|
||||
if this.UserPlan != nil {
|
||||
err := this.UserPlan.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
results = append(results, err)
|
||||
}
|
||||
|
||||
if this.UserPlan.Plan != nil {
|
||||
|
||||
Reference in New Issue
Block a user