Add pprof endpoint when running in dev mode (#708)
This commit is contained in:
+10
-8
@@ -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),
|
||||
|
||||
@@ -24,6 +24,10 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
import (
|
||||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*LivekitServer, error) {
|
||||
|
||||
Reference in New Issue
Block a user