File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ type Config struct {
6565 // If not set, it defaults to "warn".
6666 LogLevel string `mapstructure:"logLevel"`
6767
68+ // EnableProfiler enables the pprof profiler on the server.
69+ // This is not recommended for production use.
70+ EnableProfiler bool `mapstructure:"enableProfiler"`
71+
6872 // ReloadFunc is called when a reload is done via http api.
6973 ReloadFunc func ()
7074
Original file line number Diff line number Diff line change 11package redirector
22
33import (
4+ "net/http"
5+
46 "github.com/armbian/redirector/middleware"
5- "github.com/chi-middleware/logrus-logger"
7+ logger "github.com/chi-middleware/logrus-logger"
68 "github.com/go-chi/chi/v5"
9+ cm "github.com/go-chi/chi/v5/middleware"
710 lru "github.com/hashicorp/golang-lru"
811 "github.com/oschwald/maxminddb-golang"
912 "github.com/prometheus/client_golang/prometheus"
1013 "github.com/prometheus/client_golang/prometheus/promauto"
1114 "github.com/prometheus/client_golang/prometheus/promhttp"
1215 log "github.com/sirupsen/logrus"
13- "net/http"
1416)
1517
1618var (
@@ -116,6 +118,11 @@ func (r *Redirector) Start() http.Handler {
116118 router .Get ("/geoip" , r .geoIPHandler )
117119 router .Get ("/metrics" , promhttp .Handler ().ServeHTTP )
118120
121+ if r .config .EnableProfiler {
122+ log .Warn ("Enabling pprof profiler endpoints" )
123+ router .Mount ("/debug" , cm .Profiler ())
124+ }
125+
119126 router .NotFound (r .redirectHandler )
120127
121128 if r .config .BindAddress != "" {
You can’t perform that action at this time.
0 commit comments