MCPcopy
hub / github.com/livekit/livekit / startServer

Function startServer

cmd/server/main.go:247–321  ·  view source on GitHub ↗
(ctx context.Context, c *cli.Command)

Source from the content-addressed store, hash-verified

245}
246
247func 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 {

Callers

nothing calls this directly

Calls 13

NodeIDMethod · 0.95
NodeTypeMethod · 0.95
NewLocalNodeFunction · 0.92
InitFunction · 0.92
InitializeServerFunction · 0.92
getConfigFunction · 0.85
ValidateKeysMethod · 0.80
LoadTURNSecretsMethod · 0.80
CreateMethod · 0.80
CloseMethod · 0.65
StopMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected