(ctx context.Context, c *cli.Command)
| 245 | } |
| 246 | |
| 247 | func startServer(ctx context.Context, c *cli.Command) error { |
| 248 | conf, err := getConfig(c) |
| 249 | if err != nil { |
| 250 | return err |
| 251 | } |
| 252 | if url := conf.Trace.JaegerURL; url != "" { |
| 253 | jaeger.Configure(ctx, url, "livekit") |
| 254 | } |
| 255 | |
| 256 | // validate API key length |
| 257 | err = conf.ValidateKeys() |
| 258 | if err != nil { |
| 259 | return err |
| 260 | } |
| 261 | |
| 262 | if err = conf.LoadTURNSecrets(); err != nil { |
| 263 | return err |
| 264 | } |
| 265 | |
| 266 | if cpuProfile := c.String("cpuprofile"); cpuProfile != "" { |
| 267 | if f, err := os.Create(cpuProfile); err != nil { |
| 268 | return err |
| 269 | } else { |
| 270 | if err := pprof.StartCPUProfile(f); err != nil { |
| 271 | f.Close() |
| 272 | return err |
| 273 | } |
| 274 | defer func() { |
| 275 | pprof.StopCPUProfile() |
| 276 | f.Close() |
| 277 | }() |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | if memProfile := c.String("memprofile"); memProfile != "" { |
| 282 | if f, err := os.Create(memProfile); err != nil { |
| 283 | return err |
| 284 | } else { |
| 285 | defer func() { |
| 286 | // run memory profile at termination |
| 287 | runtime.GC() |
| 288 | _ = pprof.WriteHeapProfile(f) |
| 289 | _ = f.Close() |
| 290 | }() |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | currentNode, err := routing.NewLocalNode(conf) |
| 295 | if err != nil { |
| 296 | return err |
| 297 | } |
| 298 | |
| 299 | if err := prometheus.Init(string(currentNode.NodeID()), currentNode.NodeType()); err != nil { |
| 300 | return err |
| 301 | } |
| 302 | |
| 303 | server, err := service.InitializeServer(conf, currentNode) |
| 304 | if err != nil { |
nothing calls this directly
no test coverage detected