Explorar o código

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

SVI %!s(int64=2) %!d(string=hai) anos
pai
achega
9ff0e8c9d4
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  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)
 	}
 }