From 72995ab9d0136857dfe2a5efd1d13a940c3bda8b Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 10 Jun 2024 18:55:07 +0200 Subject: [PATCH] Print error --- cmd/indexer/main.go | 23 +++++++++++++++-------- pkg/indexer/indexer.go | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cmd/indexer/main.go b/cmd/indexer/main.go index 1115c35..32de763 100644 --- a/cmd/indexer/main.go +++ b/cmd/indexer/main.go @@ -6,6 +6,7 @@ import ( "os/signal" "strconv" "syscall" + "time" "github.com/dipdup-io/starknet-indexer/internal/starknet" "github.com/dipdup-io/starknet-indexer/internal/storage" @@ -92,14 +93,20 @@ func main() { } if cfg.Hasura != nil { - if err := hasura.Create(ctx, hasura.GenerateArgs{ - Config: cfg.Hasura, - DatabaseConfig: cfg.Database, - Models: storage.ModelsAny, - Views: views, - }); err != nil { - log.Panic().Err(err).Msg("hasura initialization") - return + var hasuraInitialized bool + for !hasuraInitialized { + log.Info().Msg("hasura initialization...") + if err := hasura.Create(ctx, hasura.GenerateArgs{ + Config: cfg.Hasura, + DatabaseConfig: cfg.Database, + Models: storage.ModelsAny, + Views: views, + }); err != nil { + log.Err(err).Msg("hasura initialization. waiting 5 seconds and trying again.") + time.Sleep(time.Second * 5) + } else { + hasuraInitialized = true + } } } diff --git a/pkg/indexer/indexer.go b/pkg/indexer/indexer.go index a4bdfa3..a812df3 100644 --- a/pkg/indexer/indexer.go +++ b/pkg/indexer/indexer.go @@ -274,7 +274,7 @@ func (indexer *Indexer) getNewBlocks(ctx context.Context) error { func (indexer *Indexer) sync(ctx context.Context) { if err := indexer.getNewBlocks(ctx); err != nil { - indexer.Log.Err(err).Msg("getNewBlocks") + indexer.Log.Error().Msgf("getNewBlocks: %s", err.Error()) } ticker := time.NewTicker(time.Second * 30)