Skip to content

🎧 Your Personal Streaming Service

Add pprof endpoint, disabled by default

Deluan1f6ec1d9f53e
diff --git a/cmd/root.go b/cmd/root.go
index 35a5743f0..f3a4af5b7 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -8,6 +8,7 @@ import (
"strings"
"time"
+ "github.com/go-chi/chi/v5/middleware"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/core"
@@ -96,6 +97,9 @@ func startServer(ctx context.Context) func() error {
core.WriteInitialMetrics()
a.MountRouter("Prometheus metrics", conf.Server.Prometheus.MetricsPath, promhttp.Handler())
}
+ if conf.Server.DevEnableProfiler {
+ a.MountRouter("Profiling", "/debug", middleware.Profiler())
+ }
if strings.HasPrefix(conf.Server.UILoginBackgroundURL, "/") {
a.MountRouter("Background images", consts.DefaultUILoginBackgroundURL, backgrounds.NewHandler())
}
diff --git a/conf/configuration.go b/conf/configuration.go
index 7525b16e8..5112e6eab 100644
--- a/conf/configuration.go
+++ b/conf/configuration.go
@@ -83,6 +83,7 @@ type configOptions struct {
// DevFlags. These are used to enable/disable debugging and incomplete features
DevLogSourceLine bool
DevLogLevels map[string]string
+ DevEnableProfiler bool
DevAutoCreateAdminPassword string
DevAutoLoginUsername string
DevActivityPanel bool
@@ -303,6 +304,7 @@ func init() {
// DevFlags. These are used to enable/disable debugging and incomplete features
viper.SetDefault("devlogsourceline", false)
+ viper.SetDefault("devenableprofiler", false)
viper.SetDefault("devautocreateadminpassword", "")
viper.SetDefault("devautologinusername", "")
viper.SetDefault("devactivitypanel", true)