Add pprof server endpoint (optional, default off)

This commit is contained in:
antanst
2025-10-16 15:06:27 +03:00
parent 8e1297a230
commit bba00a9892
3 changed files with 15 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ import (
"crypto/tls"
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"sync"
@@ -41,6 +43,16 @@ func runApp(ctx context.Context) error {
listenAddr := config.CONFIG.ListenAddr
// Start pprof HTTP server if enabled
if config.CONFIG.PprofAddr != "" {
go func() {
logger.Info("Starting pprof HTTP server", "address", config.CONFIG.PprofAddr)
if err := http.ListenAndServe(config.CONFIG.PprofAddr, nil); err != nil {
panic(fmt.Sprintf("pprof HTTP server failed: %v", err))
}
}()
}
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)