neko/server/cmd/serve.go

42 lines
753 B
Go
Raw Normal View History

2020-01-13 21:05:38 +13:00
package cmd
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"n.eko.moe/neko"
"n.eko.moe/neko/internal/types/config"
2020-01-13 21:05:38 +13:00
)
func init() {
command := &cobra.Command{
Use: "serve",
2020-01-19 12:30:09 +13:00
Short: "serve neko streaming server",
Long: `serve neko streaming server`,
2020-01-13 21:05:38 +13:00
Run: neko.Service.ServeCommand,
}
configs := []config.Config{
2020-01-19 12:30:09 +13:00
neko.Service.Server,
neko.Service.WebRTC,
2020-04-06 10:34:51 +12:00
neko.Service.Remote,
2020-09-24 18:09:02 +12:00
neko.Service.Broadcast,
2020-01-19 12:30:09 +13:00
neko.Service.WebSocket,
2020-01-13 21:05:38 +13:00
}
cobra.OnInitialize(func() {
for _, cfg := range configs {
cfg.Set()
}
neko.Service.Preflight()
})
for _, cfg := range configs {
if err := cfg.Init(command); err != nil {
2020-01-19 12:30:09 +13:00
log.Panic().Err(err).Msg("unable to run serve command")
2020-01-13 21:05:38 +13:00
}
}
root.AddCommand(command)
}