lotus/cli/wait.go

35 lines
582 B
Go
Raw Normal View History

package cli
import (
"fmt"
"time"
"github.com/urfave/cli/v2"
)
2021-03-23 23:26:12 +00:00
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")
},
}