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,15 @@ import (
|
||||
|
||||
context "github.com/SentimensRG/ctx"
|
||||
"github.com/SentimensRG/ctx/sigctx"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/namsral/flag"
|
||||
|
||||
sub "github.com/crusttech/crust/crm"
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/subscription"
|
||||
"github.com/crusttech/crust/internal/version"
|
||||
|
||||
crm "github.com/crusttech/crust/crm"
|
||||
system "github.com/crusttech/crust/system"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -22,14 +25,18 @@ func main() {
|
||||
|
||||
ctx := context.AsContext(sigctx.New())
|
||||
|
||||
flags(
|
||||
"crm",
|
||||
sub.Flags,
|
||||
auth.Flags,
|
||||
subscription.Flags,
|
||||
)
|
||||
crm.Flags("crm")
|
||||
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)
|
||||
}
|
||||
if err := crm.Init(); err != nil {
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
|
||||
@@ -46,7 +53,7 @@ func main() {
|
||||
// Disabled for now, system service is the only one that validates subscription
|
||||
// ctx = subscription.Monitor(ctx)
|
||||
|
||||
if err := sub.StartRestAPI(ctx); err != nil {
|
||||
if err := crm.StartRestAPI(ctx); err != nil {
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,15 @@ 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/messaging"
|
||||
|
||||
messaging "github.com/crusttech/crust/messaging"
|
||||
system "github.com/crusttech/crust/system"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -22,14 +25,18 @@ func main() {
|
||||
|
||||
ctx := context.AsContext(sigctx.New())
|
||||
|
||||
flags(
|
||||
"messaging",
|
||||
sub.Flags,
|
||||
auth.Flags,
|
||||
subscription.Flags,
|
||||
)
|
||||
messaging.Flags("messaging")
|
||||
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)
|
||||
}
|
||||
if err := messaging.Init(); err != nil {
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
|
||||
@@ -46,7 +53,7 @@ func main() {
|
||||
// Disabled for now, system service is the only one that validates subscription
|
||||
// ctx = subscription.Monitor(ctx)
|
||||
|
||||
if err := sub.StartRestAPI(ctx); err != nil {
|
||||
if err := messaging.StartRestAPI(ctx); err != nil {
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/crusttech/crust/internal/db"
|
||||
"github.com/crusttech/crust/internal/mail"
|
||||
"github.com/crusttech/crust/internal/metrics"
|
||||
systemService "github.com/crusttech/crust/system/service"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -53,7 +52,6 @@ func Init() error {
|
||||
})
|
||||
|
||||
// Don't change this, it needs Database
|
||||
systemService.Init()
|
||||
service.Init()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/crusttech/crust/internal/metrics"
|
||||
migrate "github.com/crusttech/crust/messaging/db"
|
||||
"github.com/crusttech/crust/messaging/internal/service"
|
||||
systemService "github.com/crusttech/crust/system/service"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -53,7 +52,6 @@ func Init() error {
|
||||
})
|
||||
|
||||
// Don't change this, it needs Database
|
||||
systemService.Init()
|
||||
service.Init()
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user