package main import ( routing "git.coopgo.io/coopgo-platform/routing-service" "github.com/rs/zerolog" "github.com/rs/zerolog/log" SolidarityServiceHandler "solidarity-service/handler" api "solidarity-service/interoperability/solidarity-api/server" grpcserver "solidarity-service/servers/grpc/server" "solidarity-service/storage" ) func main() { zerolog.TimeFieldFormat = zerolog.TimeFormatUnix cfg, err := ReadConfig() if err != nil { panic(err) } var ( service_name = cfg.GetString("name") grpc_enable = cfg.GetBool("services.grpc.enable") solidarity_api_enable = cfg.GetBool("services.solidarity-api.enable") routing_service_type = cfg.GetString("routing.type") valhalla_base_url = cfg.GetString("routing.valhalla.base_url") ) log.Info().Msg("Running " + service_name) storageService, err := storage.NewStorage(cfg) if err != nil { log.Fatal().Err(err).Msg("Could not initiate the storage service") return } routing, err := routing.NewRoutingService(routing_service_type, valhalla_base_url) if err != nil { log.Fatal().Err(err).Msg("Could not initiate the routing service") return } handler, err := SolidarityServiceHandler.NewSolidarityServiceHandler(cfg, routing, storageService) if err != nil { log.Fatal().Err(err).Msg("Could not initiate the solidarity service handler") return } failed := make(chan error) if grpc_enable { log.Info().Msg("Running gRPC server") go grpcserver.Run(failed, cfg, handler) } if solidarity_api_enable { log.Info().Msg("Running OCSS REST API") go api.Run(cfg, handler, storageService) } err = <-failed log.Fatal().Err(err).Msg("Terminating") }