From 124b718eb6d6fdbe023672a0cb8100543c145d42 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 17 Jul 2023 11:49:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=9C=8D=E5=8A=A1=E4=B8=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=8D=E5=8A=A1=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/boot/boot.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/boot/boot.go b/internal/boot/boot.go index 184084c..9871ce4 100644 --- a/internal/boot/boot.go +++ b/internal/boot/boot.go @@ -41,11 +41,23 @@ func Boot(initData *g_structs.InitData) (err error) { // bootCheck 测试初次启动任务 func bootCheck(initData *g_structs.InitData) (err error) { + var ctx = context.Background() + // 判断是否在更新中 + if gcache.MustGet(ctx, g_cache.UpdateCacheKey).Bool() { + glog.Warning(ctx, "正在更新客户端程序,跳过本次测速") + return + } + // 设置测速状态 + _ = gcache.Set(ctx, g_cache.SpeedCacheKey, true, 0) + err = cli_utils.CmdCore.StartSpeedCmd(context.Background(), initData) if err != nil { glog.Error(context.Background(), "测试测速服务", err) return } + // 移除测速状态 + _, _ = gcache.Remove(ctx, g_cache.SpeedCacheKey) + err = net_utils.NetUtils.CoreLatency(initData) if err != nil { glog.Error(context.Background(), "HTTPS延迟检测失败: ", err) @@ -74,7 +86,7 @@ func bootMethod(initData *g_structs.InitData) (err error) { glog.Debug(ctx, "初始化定时任务管理器服务成功") glog.Debug(ctx, "开始初始化自动更新服务") - _, err = gcron.AddSingleton(ctx, "@every 20s", func(ctx context.Context) { + _, err = gcron.AddSingleton(ctx, "@every 5s", func(ctx context.Context) { err := update_utils.AutoUpdate.UpdateCore(ctx, initData) if err != nil { glog.Error(ctx, "自动更新服务失败: ", err) From 515380dab55a14abe88d805bcaa916ec5a408669 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 17 Jul 2023 11:49:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?update:=20=E6=B5=8B=E9=80=9F=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=BC=93=E5=AD=98=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=B8=8D=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utility/cron_utils/cron_manage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/cron_utils/cron_manage.go b/utility/cron_utils/cron_manage.go index 0d06d64..d3fb2ac 100644 --- a/utility/cron_utils/cron_manage.go +++ b/utility/cron_utils/cron_manage.go @@ -167,7 +167,7 @@ func addSpeedCron(ctx context.Context, initData *g_structs.InitData, timePattern glog.Warning(ctx, "正在更新客户端程序,跳过本次测速") return } - _ = gcache.Set(ctx, g_cache.SpeedCacheKey, true, 1*time.Minute) + _ = gcache.Set(ctx, g_cache.SpeedCacheKey, true, 0) err := cli_utils.CmdCore.StartSpeedCmd(ctx, initData) if err != nil { From 78cf61a51fab83f8d7b1d501dd4127830833cada Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 17 Jul 2023 11:51:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?update:=20=E8=87=AA=E5=8A=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=9C=8D=E5=8A=A1=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E6=94=B9=E4=B8=BA20s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/boot/boot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/boot/boot.go b/internal/boot/boot.go index 9871ce4..146f400 100644 --- a/internal/boot/boot.go +++ b/internal/boot/boot.go @@ -86,7 +86,7 @@ func bootMethod(initData *g_structs.InitData) (err error) { glog.Debug(ctx, "初始化定时任务管理器服务成功") glog.Debug(ctx, "开始初始化自动更新服务") - _, err = gcron.AddSingleton(ctx, "@every 5s", func(ctx context.Context) { + _, err = gcron.AddSingleton(ctx, "@every 20s", func(ctx context.Context) { err := update_utils.AutoUpdate.UpdateCore(ctx, initData) if err != nil { glog.Error(ctx, "自动更新服务失败: ", err)