2020-01-13 21:05:38 +13:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2021-10-06 09:38:24 +13:00
|
|
|
"m1k1o/neko"
|
2022-09-13 08:18:18 +12:00
|
|
|
"m1k1o/neko/internal/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,
|
2022-09-13 08:12:47 +12:00
|
|
|
neko.Service.Capture,
|
|
|
|
neko.Service.Desktop,
|
2020-09-27 23:06:13 +13: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)
|
|
|
|
}
|