Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion management/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ package main
import (
"log"
"net/http"

// nolint:gosec
_ "net/http/pprof"
"os"

"github.com/netbirdio/netbird/management/cmd"
)

func pprofAddr() string {
listenAddr := os.Getenv("NB_PPROF_ADDR")
if listenAddr == "" {
return "localhost:6060"
}

return listenAddr
}

func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
log.Println(http.ListenAndServe(pprofAddr(), nil))
}()
if err := cmd.Execute(); err != nil {
os.Exit(1)
Expand Down
17 changes: 15 additions & 2 deletions signal/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"net"
"net/http"
"os"

// nolint:gosec
_ "net/http/pprof"
"time"
Expand Down Expand Up @@ -194,10 +196,21 @@ var (
}
)

func pprofAddr() string {
listenAddr := os.Getenv("NB_PPROF_ADDR")
if listenAddr == "" {
return "localhost:6060"
}

return listenAddr
}

func startPprof() {
listenAddr := pprofAddr()

go func() {
log.Debugf("Starting pprof server on 127.0.0.1:6060")
if err := http.ListenAndServe("127.0.0.1:6060", nil); err != nil {
log.Debugf("Starting pprof server on: %s", listenAddr)
if err := http.ListenAndServe(listenAddr, nil); err != nil {
log.Fatalf("pprof server failed: %v", err)
}
}()
Expand Down
Loading