From b0b72c19c92f68f69dd8d444b1ce5a40622892d3 Mon Sep 17 00:00:00 2001 From: zu1k Date: Sat, 15 Aug 2020 19:26:14 +0800 Subject: [PATCH] add debug tool --- checker/check.go | 2 +- main.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/checker/check.go b/checker/check.go index d859a01..496a084 100644 --- a/checker/check.go +++ b/checker/check.go @@ -30,8 +30,8 @@ func Check(p proxy.Proxy) (delay uint16, err error) { return } ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout) + defer cancel() delay, err = clashProxy.URLTest(ctx, "http://www.gstatic.com/generate_204") - cancel() return delay, err } diff --git a/main.go b/main.go index 753de9b..def9e7b 100644 --- a/main.go +++ b/main.go @@ -3,12 +3,15 @@ package main import ( "flag" "fmt" + "net/http" "github.com/zu1k/proxypool/api" "github.com/zu1k/proxypool/app" ) func main() { + go pprof() + filePath := flag.String("c", "", "path to config file: source.yaml") flag.Parse() if *filePath == "" { @@ -22,3 +25,10 @@ func main() { api.Run() } + +func pprof() { + ip := "127.0.0.1:6060" + if err := http.ListenAndServe(ip, nil); err != nil { + fmt.Printf("start pprof failed on %s\n", ip) + } +}