2020-10-23 03:54:50 +13:00
|
|
|
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"
|
2020-10-23 03:54:50 +13:00
|
|
|
)
|
|
|
|
|
|
|
|
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,
|
2020-10-23 03:54:50 +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 {
|
|
|
|
log.Panic().Err(err).Msg("unable to run serve command")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
root.AddCommand(command)
|
|
|
|
}
|