enable pprof

This commit is contained in:
Maycon Santos
2025-05-09 06:05:04 +02:00
parent 93a0315120
commit 760d61c7a3
2 changed files with 16 additions and 0 deletions

View File

@@ -134,6 +134,7 @@ var (
},
RunE: func(cmd *cobra.Command, args []string) error {
flag.Parse()
startPprof()
ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()

View File

@@ -2,9 +2,13 @@ package cmd
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"runtime"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/netbirdio/netbird/management/server/types"
@@ -17,6 +21,17 @@ const (
idpSignKeyRefreshEnabledFlagName = "idp-sign-key-refresh-enabled"
)
func startPprof() {
go func() {
runtime.SetBlockProfileRate(1)
runtime.SetMutexProfileFraction(1)
log.Debugf("Starting pprof server on 0.0.0.0:6060")
if err := http.ListenAndServe("0.0.0.0:6060", nil); err != nil {
log.Fatalf("pprof server failed: %v", err)
}
}()
}
var (
dnsDomain string
mgmtDataDir string