fix(all): better system Init, flags
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/namsral/flag"
|
||||
)
|
||||
|
||||
func flags(prefix string, mountFlags ...func(...string)) {
|
||||
for _, mount := range mountFlags {
|
||||
mount(prefix)
|
||||
}
|
||||
flag.Parse()
|
||||
}
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
|
||||
context "github.com/SentimensRG/ctx"
|
||||
"github.com/SentimensRG/ctx/sigctx"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/namsral/flag"
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/subscription"
|
||||
"github.com/crusttech/crust/internal/version"
|
||||
sub "github.com/crusttech/crust/system"
|
||||
|
||||
system "github.com/crusttech/crust/system"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -22,14 +24,14 @@ func main() {
|
||||
|
||||
ctx := context.AsContext(sigctx.New())
|
||||
|
||||
flags(
|
||||
"system",
|
||||
sub.Flags,
|
||||
auth.Flags,
|
||||
subscription.Flags,
|
||||
)
|
||||
system.Flags("system")
|
||||
|
||||
if err := sub.Init(); err != nil {
|
||||
auth.Flags()
|
||||
subscription.Flags()
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if err := system.Init(); err != nil {
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ func main() {
|
||||
// Checks subscription, will os.Exit(1) if there is an error
|
||||
ctx = subscription.Monitor(ctx)
|
||||
|
||||
if err := sub.StartRestAPI(ctx); err != nil {
|
||||
if err := system.StartRestAPI(ctx); err != nil {
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user