mirror of
https://github.com/elyby/chrly.git
synced 2025-01-11 14:22:14 +05:30
Cleanup cmd runner
This commit is contained in:
parent
d363433c88
commit
5d7a66311d
@ -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() {
|
||||
|
@ -1,5 +1,4 @@
|
||||
//go:build profiling
|
||||
// +build profiling
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -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")
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user