2020-01-13 08:05:38 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2021-10-05 22:38:24 +02:00
|
|
|
"m1k1o/neko"
|
2022-09-12 22:18:18 +02:00
|
|
|
"m1k1o/neko/internal/config"
|
2020-01-13 08:05:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
command := &cobra.Command{
|
|
|
|
Use: "serve",
|
2020-01-18 23:30:09 +00:00
|
|
|
Short: "serve neko streaming server",
|
|
|
|
Long: `serve neko streaming server`,
|
2020-01-13 08:05:38 +00:00
|
|
|
Run: neko.Service.ServeCommand,
|
|
|
|
}
|
|
|
|
|
|
|
|
configs := []config.Config{
|
2020-01-18 23:30:09 +00:00
|
|
|
neko.Service.Server,
|
|
|
|
neko.Service.WebRTC,
|
2022-09-12 22:12:47 +02:00
|
|
|
neko.Service.Capture,
|
|
|
|
neko.Service.Desktop,
|
2020-09-27 12:06:13 +02:00
|
|
|
neko.Service.Broadcast,
|
2020-01-18 23:30:09 +00:00
|
|
|
neko.Service.WebSocket,
|
2020-01-13 08:05:38 +00: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-18 23:30:09 +00:00
|
|
|
log.Panic().Err(err).Msg("unable to run serve command")
|
2020-01-13 08:05:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
root.AddCommand(command)
|
|
|
|
}
|