mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 13:10:24 +08:00 
			
		
		
		
	服务分模块加载,防止某个模块加载失败时相互受影响
This commit is contained in:
		@@ -100,10 +100,12 @@ func (this *NodeConfig) Init() (err error, serverErrors []*ServerError) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// servers
 | 
						// servers
 | 
				
			||||||
	for _, server := range this.Servers {
 | 
						for _, server := range this.Servers {
 | 
				
			||||||
		err = server.Init()
 | 
							errs := server.Init()
 | 
				
			||||||
		if err != nil {
 | 
							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{}
 | 
						return &ServerConfig{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *ServerConfig) Init() error {
 | 
					func (this *ServerConfig) Init() (results []error) {
 | 
				
			||||||
	// 分解Group
 | 
						// 分解Group
 | 
				
			||||||
	if this.Group != nil && this.Group.IsOn {
 | 
						if this.Group != nil && this.Group.IsOn {
 | 
				
			||||||
		// reverse proxy
 | 
							// reverse proxy
 | 
				
			||||||
@@ -166,63 +166,63 @@ func (this *ServerConfig) Init() error {
 | 
				
			|||||||
	if this.HTTP != nil {
 | 
						if this.HTTP != nil {
 | 
				
			||||||
		err := this.HTTP.Init()
 | 
							err := this.HTTP.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.HTTPS != nil {
 | 
						if this.HTTPS != nil {
 | 
				
			||||||
		err := this.HTTPS.Init()
 | 
							err := this.HTTPS.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.TCP != nil {
 | 
						if this.TCP != nil {
 | 
				
			||||||
		err := this.TCP.Init()
 | 
							err := this.TCP.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.TLS != nil {
 | 
						if this.TLS != nil {
 | 
				
			||||||
		err := this.TLS.Init()
 | 
							err := this.TLS.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.Unix != nil {
 | 
						if this.Unix != nil {
 | 
				
			||||||
		err := this.Unix.Init()
 | 
							err := this.Unix.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.UDP != nil {
 | 
						if this.UDP != nil {
 | 
				
			||||||
		err := this.UDP.Init()
 | 
							err := this.UDP.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.ReverseProxyRef != nil {
 | 
						if this.ReverseProxyRef != nil {
 | 
				
			||||||
		err := this.ReverseProxyRef.Init()
 | 
							err := this.ReverseProxyRef.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.ReverseProxy != nil {
 | 
						if this.ReverseProxy != nil {
 | 
				
			||||||
		err := this.ReverseProxy.Init()
 | 
							err := this.ReverseProxy.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.Web != nil {
 | 
						if this.Web != nil {
 | 
				
			||||||
		err := this.Web.Init()
 | 
							err := this.Web.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -230,7 +230,7 @@ func (this *ServerConfig) Init() error {
 | 
				
			|||||||
	if this.UserPlan != nil {
 | 
						if this.UserPlan != nil {
 | 
				
			||||||
		err := this.UserPlan.Init()
 | 
							err := this.UserPlan.Init()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								results = append(results, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if this.UserPlan.Plan != nil {
 | 
							if this.UserPlan.Plan != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user