package main import ( "os" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "git.coopgo.io/coopgo-platform/diags/grpcapi" "git.coopgo.io/coopgo-platform/diags/handlers" "git.coopgo.io/coopgo-platform/diags/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") 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 { panic(err) } 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) } // Terminate if one of the services fails err = <-failed log.Fatal().Err(err).Msg("Terminating server") }