MCPcopy Index your code
hub / github.com/screego/server / serveCmd

Function serveCmd

cmd/serve.go:18–59  ·  view source on GitHub ↗
(version string)

Source from the content-addressed store, hash-verified

16)
17
18func serveCmd(version string) cli.Command {
19 return cli.Command{
20 Name: "serve",
21 Action: func(ctx *cli.Context) {
22 conf, errs := config.Get()
23 logger.Init(conf.LogLevel.AsZeroLogLevel())
24
25 exit := false
26 for _, err := range errs {
27 log.WithLevel(err.Level).Msg(err.Msg)
28 exit = exit || err.Level == zerolog.FatalLevel || err.Level == zerolog.PanicLevel
29 }
30 if exit {
31 os.Exit(1)
32 }
33
34 if _, _, err := conf.TurnIPProvider.Get(); err != nil {
35 // error is already logged by .Get()
36 os.Exit(1)
37 }
38
39 users, err := auth.ReadPasswordsFile(conf.UsersFile, conf.Secret, conf.SessionTimeoutSeconds)
40 if err != nil {
41 log.Fatal().Str("file", conf.UsersFile).Err(err).Msg("While loading users file")
42 }
43
44 tServer, err := turn.Start(conf)
45 if err != nil {
46 log.Fatal().Err(err).Msg("could not start turn server")
47 }
48
49 rooms := ws.NewRooms(tServer, users, conf)
50
51 go rooms.Start()
52
53 r := router.Router(conf, rooms, users, version)
54 if err := server.Start(r, conf.ServerAddress, conf.TLSCertFile, conf.TLSKeyFile); err != nil {
55 log.Fatal().Err(err).Msg("http server")
56 }
57 },
58 }
59}

Callers 1

RunFunction · 0.85

Calls 10

StartMethod · 0.95
GetFunction · 0.92
InitFunction · 0.92
ReadPasswordsFileFunction · 0.92
StartFunction · 0.92
NewRoomsFunction · 0.92
RouterFunction · 0.92
StartFunction · 0.92
AsZeroLogLevelMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected