neko/cmd/serve.go

43 lines
841 B
Go
Raw Normal View History

package cmd
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
2020-10-29 07:15:48 +13:00
"demodesk/neko"
2020-12-13 06:37:19 +13:00
"demodesk/neko/modules"
2020-11-02 04:09:48 +13:00
"demodesk/neko/internal/config"
)
func init() {
command := &cobra.Command{
Use: "serve",
Short: "serve neko streaming server",
Long: `serve neko streaming server`,
Run: neko.Service.ServeCommand,
}
2020-12-13 06:37:19 +13:00
configs := append([]config.Config{
2020-11-04 12:27:47 +13:00
neko.Service.Configs.Desktop,
2020-11-02 04:09:48 +13:00
neko.Service.Configs.Capture,
2020-11-01 04:40:33 +13:00
neko.Service.Configs.WebRTC,
2020-11-02 06:39:12 +13:00
neko.Service.Configs.Session,
neko.Service.Configs.Server,
2020-12-13 06:37:19 +13:00
}, modules.ConfigsList()...)
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)
}