From 5d7a66311d0f396aac5ec862522121db18220445 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 7 Feb 2024 14:29:52 +0100 Subject: [PATCH] Cleanup cmd runner --- internal/cmd/root.go | 9 +++++---- internal/cmd/root_profiling.go | 1 - internal/cmd/serve.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 7247247..7d0c801 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -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() { diff --git a/internal/cmd/root_profiling.go b/internal/cmd/root_profiling.go index 7e0d5c2..542e657 100644 --- a/internal/cmd/root_profiling.go +++ b/internal/cmd/root_profiling.go @@ -1,5 +1,4 @@ //go:build profiling -// +build profiling package cmd diff --git a/internal/cmd/serve.go b/internal/cmd/serve.go index 91a1b94..9a9246f 100644 --- a/internal/cmd/serve.go +++ b/internal/cmd/serve.go @@ -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") }, }