mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-07 15:20:24 +08:00
每个服务只初始化一次
This commit is contained in:
@@ -172,6 +172,11 @@ func (this *NodeConfig) Init() (err error, serverErrors []*ServerError) {
|
|||||||
|
|
||||||
// servers
|
// servers
|
||||||
for _, server := range this.Servers {
|
for _, server := range this.Servers {
|
||||||
|
// 避免在运行时重新初始化
|
||||||
|
if server.IsInitialized() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
errs := server.Init()
|
errs := server.Init()
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ type ServerConfig struct {
|
|||||||
// UAM
|
// UAM
|
||||||
UAM *UAMConfig `yaml:"uam" json:"uam"`
|
UAM *UAMConfig `yaml:"uam" json:"uam"`
|
||||||
|
|
||||||
|
isInitialized bool
|
||||||
|
|
||||||
isOk bool
|
isOk bool
|
||||||
|
|
||||||
planId int64
|
planId int64
|
||||||
@@ -79,6 +81,11 @@ func NewServerConfig() *ServerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerConfig) Init() (results []error) {
|
func (this *ServerConfig) Init() (results []error) {
|
||||||
|
if this.isInitialized {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.isInitialized = true
|
||||||
|
|
||||||
// 分解Group
|
// 分解Group
|
||||||
if this.Group != nil && this.Group.IsOn {
|
if this.Group != nil && this.Group.IsOn {
|
||||||
// reverse proxy
|
// reverse proxy
|
||||||
@@ -266,6 +273,10 @@ func (this *ServerConfig) Init() (results []error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ServerConfig) IsInitialized() bool {
|
||||||
|
return this.isInitialized
|
||||||
|
}
|
||||||
|
|
||||||
// IsOk 配置是否正确
|
// IsOk 配置是否正确
|
||||||
func (this *ServerConfig) IsOk() bool {
|
func (this *ServerConfig) IsOk() bool {
|
||||||
return this.isOk
|
return this.isOk
|
||||||
|
|||||||
Reference in New Issue
Block a user