From 4e32764c87a55b9456bf0ee2766316df5f5e0d02 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 31 Oct 2022 16:04:50 +0800 Subject: [PATCH] adjust: add some log for healthcheck debug --- adapter/provider/healthcheck.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/adapter/provider/healthcheck.go b/adapter/provider/healthcheck.go index bf8bcc6a..16b9ad61 100644 --- a/adapter/provider/healthcheck.go +++ b/adapter/provider/healthcheck.go @@ -2,12 +2,14 @@ package provider import ( "context" - "github.com/Dreamacro/clash/common/singledo" "time" "github.com/Dreamacro/clash/common/batch" + "github.com/Dreamacro/clash/common/singledo" C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/clash/log" + "github.com/gofrs/uuid" "go.uber.org/atomic" ) @@ -55,6 +57,7 @@ func (hc *HealthCheck) lazyCheck() bool { hc.check() return true } else { + log.Debugln("Skip once health check because we are lazy") return false } } @@ -73,18 +76,26 @@ func (hc *HealthCheck) touch() { func (hc *HealthCheck) check() { _, _, _ = hc.singleDo.Do(func() (struct{}, error) { + id := "" + if uid, err := uuid.NewV4(); err == nil { + id = uid.String() + } + log.Debugln("Start New Health Checking {%s}", id) b, _ := batch.New[bool](context.Background(), batch.WithConcurrencyNum[bool](10)) for _, proxy := range hc.proxies { p := proxy b.Go(p.Name(), func() (bool, error) { ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout) defer cancel() + log.Debugln("Health Checking %s {%s}", p.Name(), id) _, _ = p.URLTest(ctx, hc.url) + log.Debugln("Health Checked %s : %t %d ms {%s}", p.Name(), p.Alive(), p.LastDelay(), id) return false, nil }) } b.Wait() + log.Debugln("Finish A Health Checking {%s}", id) return struct{}{}, nil }) }