소스 검색

d04 Разведение профилировщика по разным портам

SVI 2 년 전
부모
커밋
9ff0e8c9d4
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      cmd/server/main.go

+ 6 - 1
cmd/server/main.go

@@ -13,6 +13,7 @@ import (
 	"net/http"
 	_ "net/http/pprof"
 	"os"
+	"time"
 
 	"wartank/server"
 )
@@ -24,7 +25,11 @@ func profile() {
 		port = "8081"
 	}
 	for {
-		http.ListenAndServe("0.0.0.0:"+port, nil)
+		err := http.ListenAndServe("0.0.0.0:"+port, nil)
+		if err != nil {
+			log.Printf("profile(): in run pprof, err=\n\t%v\n", err)
+		}
+		time.Sleep(time.Second * 1)
 	}
 }