From c199647e52bf3765ae42d4f6d1989658c2f29aee Mon Sep 17 00:00:00 2001 From: Ethan Reesor Date: Tue, 2 Jul 2024 19:34:27 +0000 Subject: [PATCH] Tweak --- cmd/accumulated/run/router.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/accumulated/run/router.go b/cmd/accumulated/run/router.go index 42986b84f..73201a1d4 100644 --- a/cmd/accumulated/run/router.go +++ b/cmd/accumulated/run/router.go @@ -7,6 +7,8 @@ package run import ( + "log/slog" + "gitlab.com/accumulatenetwork/accumulate/exp/apiutil" "gitlab.com/accumulatenetwork/accumulate/exp/ioc" "gitlab.com/accumulatenetwork/accumulate/internal/api/routing" @@ -56,7 +58,20 @@ func (r *RouterService) create(inst *Instance) (routing.Router, error) { } } - return apiutil.InitRouter(opts) + router, err := apiutil.InitRouter(opts) + if err != nil { + return nil, err + } + + go func() { + if !<-router.(*routing.RouterInstance).Ready() { + // Failed to initialize router + slog.ErrorContext(inst.context, "Shutting down", "error", "failed to initialize router") + inst.shutdown() + } + }() + + return router, nil } func (r *RouterService) start(inst *Instance) error {