lotus/cli/wait.go
Jakub Sztandera 624f5969b3
fix: wait-api should use GetAPI to acquire binary specific API
Fixes #6244

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2021-05-13 19:58:15 +02:00

35 lines
582 B
Go

package cli
import (
"fmt"
"time"
"github.com/urfave/cli/v2"
)
var WaitApiCmd = &cli.Command{
Name: "wait-api",
Usage: "Wait for lotus api to come online",
Action: func(cctx *cli.Context) error {
for i := 0; i < 30; i++ {
api, closer, err := GetAPI(cctx)
if err != nil {
fmt.Printf("Not online yet... (%s)\n", err)
time.Sleep(time.Second)
continue
}
defer closer()
ctx := ReqContext(cctx)
_, err = api.ID(ctx)
if err != nil {
return err
}
return nil
}
return fmt.Errorf("timed out waiting for api to come online")
},
}