Add pprof server endpoint (optional, default off)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user