Add pprof endpoint when running in dev mode (#708)

This commit is contained in:
David Zhao
2022-05-23 00:34:16 -07:00
committed by GitHub
parent 96b095504b
commit a933f1513f
5 changed files with 15 additions and 29 deletions
+10 -8
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"runtime/pprof"
"time"
@@ -16,13 +17,12 @@ import (
"github.com/urfave/negroni"
"go.uber.org/atomic"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/version"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
type LivekitServer struct {
@@ -85,16 +85,18 @@ func NewLivekitServer(conf *config.Config,
recServer := livekit.NewRecordingServiceServer(recService)
mux := http.NewServeMux()
if conf.Development {
// pprof handlers are registered onto DefaultServeMux
mux = http.DefaultServeMux
mux.HandleFunc("/debug/goroutine", s.debugGoroutines)
mux.HandleFunc("/debug/rooms", s.debugInfo)
}
mux.Handle(roomServer.PathPrefix(), roomServer)
mux.Handle(egressServer.PathPrefix(), egressServer)
mux.Handle(recServer.PathPrefix(), recServer)
mux.Handle("/rtc", rtcService)
mux.HandleFunc("/rtc/validate", rtcService.Validate)
mux.HandleFunc("/", s.healthCheck)
if conf.Development {
mux.HandleFunc("/debug/goroutine", s.debugGoroutines)
mux.HandleFunc("/debug/rooms", s.debugInfo)
}
s.httpServer = &http.Server{
Addr: fmt.Sprintf(":%d", conf.Port),