Skip to content

Commit

Permalink
fix(f3): auto-restart F3 service on errors (#4957)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Oct 31, 2024
1 parent cbf0eeb commit 9bebafd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion f3-sidecar/ffi_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"os"
"time"

logging "github.com/ipfs/go-log/v2"
)
Expand All @@ -26,7 +27,17 @@ type f3Impl struct {
}

func (f3 *f3Impl) run(rpc_endpoint string, jwt string, f3_rpc_endpoint string, initial_power_table string, bootstrap_epoch int64, finality int64, db string, manifest_server string) bool {
err := run(f3.ctx, rpc_endpoint, jwt, f3_rpc_endpoint, initial_power_table, bootstrap_epoch, finality, db, manifest_server)
var err error = nil
const MAX_RETRY int = 5
nRetry := 0
for nRetry <= MAX_RETRY {
err = run(f3.ctx, rpc_endpoint, jwt, f3_rpc_endpoint, initial_power_table, bootstrap_epoch, finality, db, manifest_server)
if err != nil {
nRetry += 1
logger.Errorf("Unexpected F3 failure, retrying(%d) in 10s... error=%s", nRetry, err)
time.Sleep(10 * time.Second)
}
}
return err == nil
}

Expand Down

0 comments on commit 9bebafd

Please sign in to comment.