cmd/derper, derp: add some more varz and consistency check handler

I'm trying to hunt down a slow drift in numbers not agreeing.
This commit is contained in:
Brad Fitzpatrick
2020-06-23 13:59:48 -07:00
parent c2682553ff
commit b87396b5d9
2 changed files with 57 additions and 2 deletions

View File

@ -204,6 +204,15 @@ func main() {
func debugHandler(s *derp.Server) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.RequestURI == "/debug/check" {
err := s.ConsistencyCheck()
if err != nil {
http.Error(w, err.Error(), 500)
} else {
io.WriteString(w, "derp.Server ConsistencyCheck okay")
}
return
}
f := func(format string, args ...interface{}) { fmt.Fprintf(w, format, args...) }
f(`<html><body>
<h1>DERP debug</h1>
@ -218,6 +227,7 @@ func debugHandler(s *derp.Server) http.Handler {
<li><a href="/debug/pprof/">/debug/pprof/</a></li>
<li><a href="/debug/pprof/goroutine?debug=1">/debug/pprof/goroutine</a> (collapsed)</li>
<li><a href="/debug/pprof/goroutine?debug=2">/debug/pprof/goroutine</a> (full)</li>
<li><a href="/debug/check">/debug/check</a> internal consistency check</li>
<ul>
</html>
`)