From dd460bc40d1285373d33a87ec251f01d768f0695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 22 Sep 2022 11:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E6=9C=8D=E5=8A=A1=E5=8F=AA?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/nodeconfigs/node_config.go | 5 +++++ pkg/serverconfigs/server_config.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/nodeconfigs/node_config.go b/pkg/nodeconfigs/node_config.go index 9411f0d..778541c 100644 --- a/pkg/nodeconfigs/node_config.go +++ b/pkg/nodeconfigs/node_config.go @@ -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 { diff --git a/pkg/serverconfigs/server_config.go b/pkg/serverconfigs/server_config.go index 1e6c6dd..db4b3c8 100644 --- a/pkg/serverconfigs/server_config.go +++ b/pkg/serverconfigs/server_config.go @@ -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