Skip to content

Commit 3133430

Browse files
committed
Fix pprof server stdout race in tests
1 parent 0d72895 commit 3133430

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cmd/cimis/profile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func runProfile(dataDir string, args []string) error {
5252
if *server != "" {
5353
pprofServer := profile.StartPProfServer(*server)
5454
fmt.Printf("pprof server started on %s\n", *server)
55+
fmt.Printf(" CPU profile: curl http://%s/debug/pprof/profile\n", *server)
56+
fmt.Printf(" Heap: curl http://%s/debug/pprof/heap\n", *server)
57+
fmt.Printf(" Goroutines: curl http://%s/debug/pprof/goroutine\n", *server)
58+
fmt.Printf(" Allocs: curl http://%s/debug/pprof/allocs\n", *server)
5559
fmt.Println("Press Ctrl+C to stop...")
5660

5761
// Wait for interrupt

internal/profile/profile.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package profile
44
import (
55
"fmt"
66
"io"
7+
"log"
78
"net/http"
89
_ "net/http/pprof"
910
"os"
@@ -138,13 +139,8 @@ func StartPProfServer(addr string) *http.Server {
138139
}
139140

140141
go func() {
141-
fmt.Printf("Starting pprof server on %s\n", addr)
142-
fmt.Printf(" CPU profile: curl http://%s/debug/pprof/profile\n", addr)
143-
fmt.Printf(" Heap: curl http://%s/debug/pprof/heap\n", addr)
144-
fmt.Printf(" Goroutines: curl http://%s/debug/pprof/goroutine\n", addr)
145-
fmt.Printf(" Allocs: curl http://%s/debug/pprof/allocs\n", addr)
146142
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
147-
fmt.Printf("pprof server error: %v\n", err)
143+
log.Printf("pprof server error: %v", err)
148144
}
149145
}()
150146

0 commit comments

Comments
 (0)