neko/cmd/serve.go

42 lines
791 B
Go
Raw Normal View History

package cmd
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
2020-10-29 07:15:48 +13:00
"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{
2020-11-01 04:40:33 +13:00
neko.Service.Configs.Server,
neko.Service.Configs.WebRTC,
neko.Service.Configs.Remote,
neko.Service.Configs.Broadcast,
neko.Service.Configs.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)
}