lotus/cli/wait.go
Jakub Sztandera 29dbc26dbd
Update cli
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-04 01:01:41 +02:00

35 lines
590 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 := GetFullNodeAPI(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")
},
}