package main import ( "os" "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" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) 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") dev_env = cfg.GetBool("dev_env") ) if dev_env { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } storage, err := storage.NewStorage(cfg) if err != nil { log.Panic().Err(err).Msg("Cannot connect to storage") return } handler := handlers.NewHandler(cfg, storage) failed := make(chan error) log.Info().Str("service_name", service_name).Msg("Running service") if grpc_enable { go grpcapi.Run(failed, cfg, handler) } if oidc_provider_enable { go op.Run(failed, cfg, handler, storage) } err = <-failed log.Fatal().Err(err).Msg("Terminating server") }