Skip to content

Commit

Permalink
Print error
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jun 10, 2024
1 parent 28eb72e commit 72995ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions cmd/indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 72995ab

Please sign in to comment.