From fe3b9629f578c6c4b09ae63f9309a464c22d78f0 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 30 Nov 2020 17:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9=20fix=20self=20update,=20go-update?= =?UTF-8?q?=20could=20not=20restart=20it-self?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/agent/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 78bdc11..8792539 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -48,6 +48,8 @@ var ( updateCh = make(chan struct{}, 0) ) +const AGENT_UPGRADE = 55 + func doSelfUpdate() { defer func() { time.Sleep(time.Minute * 20) @@ -64,10 +66,8 @@ func doSelfUpdate() { // latest version is the same as current version. It means current binary is up to date. log.Println("Current binary is the latest version", version) } else { - log.Println("Prev version", dao.Version) - dao.Version = latest.Version.String() - client.Register(ctx, monitor.GetHost().PB()) log.Println("Successfully updated to version", latest.Version) + os.Exit(AGENT_UPGRADE) } }