2022-08-02 10:26:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
|
|
|
"git.coopgo.io/coopgo-platform/mobility-accounts/handlers"
|
|
|
|
op "git.coopgo.io/coopgo-platform/mobility-accounts/oidc-provider"
|
|
|
|
"git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cfg, err := ReadConfig()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
service_name = cfg.GetString("name")
|
|
|
|
grpc_enable = cfg.GetBool("services.grpc.enable")
|
|
|
|
oidc_provider_enable = cfg.GetBool("services.oidc_provider.enable")
|
2023-03-29 10:59:08 +00:00
|
|
|
dev_env = cfg.GetBool("dev_env")
|
2022-08-02 10:26:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
storage, err := storage.NewStorage(cfg)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
handler := handlers.NewHandler(cfg, storage)
|
|
|
|
|
|
|
|
fmt.Println("Running", service_name, ":")
|
2023-03-29 10:59:08 +00:00
|
|
|
if dev_env {
|
|
|
|
fmt.Printf("\033]0;%s\007", service_name)
|
|
|
|
}
|
2022-08-02 10:26:28 +00:00
|
|
|
|
|
|
|
failed := make(chan error)
|
|
|
|
|
|
|
|
if grpc_enable {
|
|
|
|
go grpcapi.Run(failed, cfg, handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
if oidc_provider_enable {
|
|
|
|
go op.Run(failed, cfg, handler, storage)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = <-failed
|
|
|
|
|
|
|
|
fmt.Println("Terminating :", err)
|
|
|
|
|
|
|
|
}
|