add pprof

This commit is contained in:
Pascal Fischer
2025-03-13 15:53:35 +01:00
parent 2d82d2fb83
commit 1b3471a354
2 changed files with 16 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
"io/fs"
"net"
"net/http"
_ "net/http/pprof"
"net/netip"
"net/url"
"os"
@@ -34,6 +35,7 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/realip"
"github.com/netbirdio/management-integrations/integrations"
"github.com/netbirdio/netbird/management/server/peers"
"github.com/netbirdio/netbird/encryption"
@@ -90,6 +92,11 @@ var (
PreRunE: func(cmd *cobra.Command, args []string) error {
flag.Parse()
go func() {
log.Infof("Starting pprof on :6060")
http.ListenAndServe("localhost:6060", nil)
}()
//nolint
ctx := context.WithValue(cmd.Context(), hook.ExecutionContextKey, hook.SystemSource)
@@ -132,6 +139,7 @@ var (
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
flag.Parse()
ctx, cancel := context.WithCancel(cmd.Context())

View File

@@ -6,7 +6,9 @@ import (
b64 "encoding/base64"
"fmt"
"net"
"os"
"slices"
"strconv"
"strings"
"sync"
"time"
@@ -1235,8 +1237,12 @@ func (am *DefaultAccountManager) BufferUpdateAccountPeers(ctx context.Context, a
}
go func() {
time.Sleep(1 * time.Second)
intervalStr := os.Getenv("PEER_UPDATE_INTERVAL_MS")
interval, err := strconv.Atoi(intervalStr)
if err != nil {
interval = 10000
}
time.Sleep(time.Duration(interval) * time.Millisecond)
am.UpdateAccountPeers(ctx, accountID)
am.accountUpdateLocks.Delete(accountID)