2022-01-25 16:04:28 +00:00
|
|
|
package debug
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/pprof"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-08-03 19:33:27 +00:00
|
|
|
"goauthentik.io/internal/config"
|
2022-01-25 16:04:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func EnableDebugServer() {
|
|
|
|
l := log.WithField("logger", "authentik.go_debugger")
|
2023-01-08 13:19:08 +00:00
|
|
|
if !config.Get().Debug {
|
2022-01-25 16:04:28 +00:00
|
|
|
l.Info("not enabling debug server, set `AUTHENTIK_DEBUG` to `true` to enable it.")
|
2022-06-02 22:06:09 +00:00
|
|
|
return
|
2022-01-25 16:04:28 +00:00
|
|
|
}
|
|
|
|
h := http.NewServeMux()
|
|
|
|
h.HandleFunc("/debug/pprof/", pprof.Index)
|
|
|
|
h.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
|
|
|
h.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
|
|
|
h.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
|
|
|
h.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
2022-08-03 19:33:27 +00:00
|
|
|
l.Println(http.ListenAndServe(config.Get().Listen.Debug, nil))
|
2022-01-25 16:04:28 +00:00
|
|
|
}
|