2020-04-27 22:26:46 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2020-06-02 18:12:53 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2020-04-27 22:26:46 +00:00
|
|
|
)
|
|
|
|
|
2021-03-23 23:26:12 +00:00
|
|
|
var WaitApiCmd = &cli.Command{
|
2020-04-27 22:26:46 +00:00
|
|
|
Name: "wait-api",
|
|
|
|
Usage: "Wait for lotus api to come online",
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
for i := 0; i < 30; i++ {
|
2021-05-13 17:58:15 +00:00
|
|
|
api, closer, err := GetAPI(cctx)
|
2020-04-27 22:26:46 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Not online yet... (%s)\n", err)
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
ctx := ReqContext(cctx)
|
|
|
|
|
2021-08-03 12:07:45 +00:00
|
|
|
_, err = api.Version(ctx)
|
2020-04-27 22:26:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("timed out waiting for api to come online")
|
|
|
|
},
|
|
|
|
}
|