From 4bce0e7ed40d2ac2312c6e58a5d490dd122c675e Mon Sep 17 00:00:00 2001 From: Paul Wells Date: Sat, 3 Feb 2024 14:57:07 -0800 Subject: [PATCH] fix startup with -dev and -config (#2442) --- cmd/server/main.go | 13 ++----------- pkg/config/config.go | 8 ++++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index b9bfea418..3e8e3344d 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -29,7 +29,6 @@ import ( "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/pkg/telemetry/prometheus" - "github.com/livekit/mediatransportutil/pkg/rtcconfig" "github.com/livekit/protocol/logger" "github.com/livekit/livekit-server/pkg/config" @@ -205,11 +204,7 @@ func getConfig(c *cli.Context) (*config.Config, error) { } config.InitLoggerFromConfig(&conf.Logging) - if c.String("config") == "" && c.String("config-body") == "" && conf.Development { - // use single port UDP when no config is provided - conf.RTC.UDPPort = rtcconfig.PortRange{Start: 7882} - conf.RTC.ICEPortRangeStart = 0 - conf.RTC.ICEPortRangeEnd = 0 + if conf.Development { logger.Infow("starting in development mode") if len(conf.Keys) == 0 { @@ -248,10 +243,6 @@ func getConfig(c *cli.Context) (*config.Config, error) { } func startServer(c *cli.Context) error { - rand.Seed(time.Now().UnixNano()) - - memProfile := c.String("memprofile") - conf, err := getConfig(c) if err != nil { return err @@ -263,7 +254,7 @@ func startServer(c *cli.Context) error { return err } - if memProfile != "" { + if memProfile := c.String("memprofile"); memProfile != "" { if f, err := os.Create(memProfile); err != nil { return err } else { diff --git a/pkg/config/config.go b/pkg/config/config.go index 1a515f86f..0d18022c7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -516,16 +516,16 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c } } - if err := conf.RTC.Validate(conf.Development); err != nil { - return nil, fmt.Errorf("could not validate RTC config: %v", err) - } - if c != nil { if err := conf.updateFromCLI(c, baseFlags); err != nil { return nil, err } } + if err := conf.RTC.Validate(conf.Development); err != nil { + return nil, fmt.Errorf("could not validate RTC config: %v", err) + } + // expand env vars in filenames file, err := homedir.Expand(os.ExpandEnv(conf.KeyFile)) if err != nil {