Browse Source

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

SVI 2 years ago
parent
commit
9ff0e8c9d4
1 changed files with 6 additions and 1 deletions
  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)
 	}
 }