worker: Better miner connectivity check on startup

This commit is contained in:
Łukasz Magiera 2020-10-18 19:53:23 +02:00
parent 8c86ea6b75
commit 1a10f95973

View File

@ -172,13 +172,18 @@ var runCmd = &cli.Command{
}
// Connect to storage-miner
ctx := lcli.ReqContext(cctx)
var nodeApi api.StorageMiner
var closer func()
var err error
for {
nodeApi, closer, err = lcli.GetStorageMinerAPI(cctx, lcli.StorageMinerUseHttp)
if err == nil {
break
_, err = nodeApi.Version(ctx)
if err == nil {
break
}
}
fmt.Printf("\r\x1b[0KConnecting to miner API... (%s)", err)
time.Sleep(time.Second)
@ -186,7 +191,6 @@ var runCmd = &cli.Command{
}
defer closer()
ctx := lcli.ReqContext(cctx)
ctx, cancel := context.WithCancel(ctx)
defer cancel()