Skip to content

Commit

Permalink
fix: Add a waiting before ssh (#82)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege committed Apr 28, 2022
1 parent ac81b41 commit 9534253
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/midi/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"fmt"
"path/filepath"
"time"

"github.com/cockroachdb/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -58,6 +59,11 @@ var CommandUp = &cli.Command{
Aliases: []string{"k"},
Value: "~/.ssh/id_rsa",
},
&cli.DurationFlag{
Name: "timeout",
Usage: "Timeout of container creation",
Value: time.Second * 30,
},
},

Action: up,
Expand Down Expand Up @@ -93,6 +99,11 @@ func up(clicontext *cli.Context) error {
}
logrus.Debugf("container %s is running", containerID)

if err := dockerClient.WaitUntilRunning(
clicontext.Context, containerID, clicontext.Duration("timeout")); err != nil {
return errors.Wrap(err, "failed to wait until the container is running")
}

sshClient, err := ssh.NewClient(
containerIP, "root", 2222, clicontext.Bool("auth"), clicontext.Path("private-key"), "")
if err != nil {
Expand Down

0 comments on commit 9534253

Please sign in to comment.