Skip to content

Commit

Permalink
fix: wait for db lock (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 committed Jan 31, 2024
1 parent 980d6b5 commit 9f9e048
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ func main() {

go health.StartHealthEndpoint(cfg.Observability.HealthPort)

db, err := lvldb.NewLvlDB(cfg.Store.Path)
if err != nil {
panic(err)
var db *lvldb.LVLDB
for {
db, err = lvldb.NewLvlDB(cfg.Store.Path)
if err != nil {
log.Error().Err(err).Msg("Unable to connect to blockstore file, retry in 10 seconds")
time.Sleep(10 * time.Second)
} else {
log.Info().Msg("Successfully connected to blockstore file")
break
}
}
periodStore := store.NewPeriodStore(db)

Expand Down

0 comments on commit 9f9e048

Please sign in to comment.