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