From 06f1ab79d73ada7dc180f4cb411f3abcd5f1756e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 15 Jun 2021 10:55:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=90=AF=E5=8A=A8=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=B6=E8=87=AA=E5=8A=A8=E5=B0=9D=E8=AF=95=E4=BB=8E?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AF=BB=E5=8F=96=E7=BC=93=E5=AD=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/node.go | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/internal/nodes/node.go b/internal/nodes/node.go index 089902f..d65c2f1 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -83,23 +83,30 @@ func (this *Node) Start() { } // 读取API配置 - tryTimes := 0 - for { - err = this.syncConfig() + err = this.syncConfig() + if err != nil { + _, err := nodeconfigs.SharedNodeConfig() if err != nil { - tryTimes++ + // 无本地数据时,会尝试多次读取 + tryTimes := 0 + for { + err := this.syncConfig() + if err != nil { + tryTimes++ - if tryTimes%10 == 0 { - remotelogs.Error("NODE", err.Error()) - } - time.Sleep(1 * time.Second) + if tryTimes%10 == 0 { + remotelogs.Error("NODE", err.Error()) + } + time.Sleep(1 * time.Second) - // 不做长时间的无意义的重试 - if tryTimes > 1000 { - return + // 不做长时间的无意义的重试 + if tryTimes > 1000 { + return + } + } else { + break + } } - } else { - break } }