Skip to content

Commit

Permalink
Move pprof to metrics router (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont authored Apr 21, 2024
1 parent 9375b09 commit bd04792
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ func (h *Headscale) ensureUnixSocketIsAbsent() error {
func (h *Headscale) createRouter(grpcMux *grpcRuntime.ServeMux) *mux.Router {
router := mux.NewRouter()
router.Use(prometheusMiddleware)
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)

router.HandleFunc(ts2021UpgradePath, h.NoiseUpgradeHandler).Methods(http.MethodPost)

Expand Down Expand Up @@ -681,7 +680,7 @@ func (h *Headscale) Serve() error {
// HTTP setup
//
// This is the regular router that we expose
// over our main Addr. It also serves the legacy Tailcale API
// over our main Addr
router := h.createRouter(grpcGatewayMux)

httpServer := &http.Server{
Expand Down Expand Up @@ -711,11 +710,10 @@ func (h *Headscale) Serve() error {
Msgf("listening and serving HTTP on: %s", h.cfg.Addr)

debugMux := http.NewServeMux()
debugMux.Handle("/debug/pprof/", http.DefaultServeMux)
debugMux.HandleFunc("/debug/notifier", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(h.nodeNotifier.String()))

return
})
debugMux.HandleFunc("/debug/mapresp", func(w http.ResponseWriter, r *http.Request) {
h.mapSessionMu.Lock()
Expand All @@ -729,8 +727,6 @@ func (h *Headscale) Serve() error {

w.WriteHeader(http.StatusOK)
w.Write([]byte(b.String()))

return
})
debugMux.Handle("/metrics", promhttp.Handler())

Expand Down

0 comments on commit bd04792

Please sign in to comment.