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