endpoint to dump stacktraces

This commit is contained in:
David Zhao
2021-06-17 22:54:09 -07:00
parent 089d1d366d
commit e527a66096
+8
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"net"
"net/http"
"runtime/pprof"
"time"
"github.com/pion/turn/v2"
@@ -68,6 +69,9 @@ func NewLivekitServer(conf *config.Config,
mux.Handle(s.roomServer.PathPrefix(), s.roomServer)
mux.Handle("/rtc", rtcService)
mux.HandleFunc("/", s.healthCheck)
if conf.Development {
mux.HandleFunc("/debug/goroutine", s.debugGoroutines)
}
s.httpServer = &http.Server{
Addr: fmt.Sprintf(":%d", conf.Port),
@@ -208,6 +212,10 @@ func (s *LivekitServer) RoomManager() *RoomManager {
return s.roomManager
}
func (s *LivekitServer) debugGoroutines(w http.ResponseWriter, r *http.Request) {
_ = pprof.Lookup("goroutine").WriteTo(w, 2)
}
func (s *LivekitServer) healthCheck(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}