Cleanup cmd runner

This commit is contained in:
ErickSkrauch 2024-02-07 14:29:52 +01:00
parent d363433c88
commit 5d7a66311d
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package cmd
import (
"log"
"strings"
. "github.com/defval/di"
@ -28,21 +27,23 @@ func shouldGetContainer() *Container {
return container
}
func startServer(modules []string) {
func startServer(modules ...string) error {
container := shouldGetContainer()
var config *viper.Viper
err := container.Resolve(&config)
if err != nil {
log.Fatal(err)
return err
}
config.Set("modules", modules)
err = container.Invoke(http.StartServer)
if err != nil {
log.Fatal(err)
return err
}
return nil
}
func init() {

View File

@ -1,5 +1,4 @@
//go:build profiling
// +build profiling
package cmd

View File

@ -7,8 +7,8 @@ import (
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Starts HTTP handler for the skins system",
Run: func(cmd *cobra.Command, args []string) {
startServer([]string{"skinsystem", "api"})
RunE: func(cmd *cobra.Command, args []string) error {
return startServer("skinsystem", "api")
},
}