We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a942e4a commit ccbabd9Copy full SHA for ccbabd9
relay/cmd/pprof.go
@@ -0,0 +1,33 @@
1
+//go:build pprof
2
+// +build pprof
3
+
4
+package cmd
5
6
+import (
7
+ "net/http"
8
+ _ "net/http/pprof"
9
+ "os"
10
11
+ log "github.com/sirupsen/logrus"
12
+)
13
14
+func init() {
15
+ addr := pprofAddr()
16
+ go pprof(addr)
17
+}
18
19
+func pprofAddr() string {
20
+ listenAddr := os.Getenv("NB_PPROF_ADDR")
21
+ if listenAddr == "" {
22
+ return "localhost:6969"
23
+ }
24
25
+ return listenAddr
26
27
28
+func pprof(listenAddr string) {
29
+ log.Infof("listening pprof on: %s\n", listenAddr)
30
+ if err := http.ListenAndServe(listenAddr, nil); err != nil {
31
+ log.Fatalf("Failed to start pprof: %v", err)
32
33
0 commit comments