neko/cmd/serve.go
2020-10-28 19:15:48 +01:00

42 lines
751 B
Go

package cmd
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"demodesk/neko"
"demodesk/neko/internal/types/config"
)
func init() {
command := &cobra.Command{
Use: "serve",
Short: "serve neko streaming server",
Long: `serve neko streaming server`,
Run: neko.Service.ServeCommand,
}
configs := []config.Config{
neko.Service.Server,
neko.Service.WebRTC,
neko.Service.Remote,
neko.Service.Broadcast,
neko.Service.WebSocket,
}
cobra.OnInitialize(func() {
for _, cfg := range configs {
cfg.Set()
}
neko.Service.Preflight()
})
for _, cfg := range configs {
if err := cfg.Init(command); err != nil {
log.Panic().Err(err).Msg("unable to run serve command")
}
}
root.AddCommand(command)
}