neko/server/cmd/serve.go

40 lines
698 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/config"
)
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,
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)
}