Skip to content

Commit

Permalink
Merge pull request #17 from hamster1963/fix-boot-check-bug
Browse files Browse the repository at this point in the history
修复启动测试服务与更新服务冲突的问题
  • Loading branch information
hamster1963 authored Jul 17, 2023
2 parents 5f6b3f1 + 78cf61a commit 44b8f0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions internal/boot/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion utility/cron_utils/cron_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 44b8f0b

Please sign in to comment.