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

View File

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

View File

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