Skip to content

Commit

Permalink
- Fix wait for docker start on macos
Browse files Browse the repository at this point in the history
- Better logging while waiting for docker
- Enable docker autostart by default on macos
  • Loading branch information
16domsim committed Nov 11, 2021
1 parent bf33c31 commit 17313b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion launcher/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"runtime"

"github.com/keinenclue/sasm-docker/launcher/internal/util"
"github.com/spf13/viper"
Expand All @@ -25,7 +26,7 @@ func SetupWithName(configPath string, configName string) error {
viper.AddConfigPath(".")
viper.SetDefault("dataPath", configPath)
viper.SetDefault("autostart.docker.path", util.GetDockerExecPath())
viper.SetDefault("autostart.docker.enabled", false)
viper.SetDefault("autostart.docker.enabled", runtime.GOOS == "darwin")
viper.SetDefault("autostart.xserver.path", util.GetXserverExecPath())
viper.SetDefault("autostart.xserver.enabled", false)

Expand Down
10 changes: 8 additions & 2 deletions launcher/internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"strings"
"time"

"github.com/containerd/containerd/log"
Expand Down Expand Up @@ -198,12 +199,17 @@ func (c *LaunchableContainer) WaitForDockerDaemon() error {
var retryCount = 0

_, err = dockerClient.ContainerList(context.Background(), types.ContainerListOptions{})
for err != nil && client.IsErrConnectionFailed(err) && retryCount < 12 {
for err != nil && (client.IsErrConnectionFailed(err) ||
strings.HasSuffix(err.Error(), "connection refused")) && retryCount < 12 {
retryCount++
c.handleContainerEvent(Event{
Type: LogMessage,
Type: ConsoleOutput,
Data: err.Error() + ", retrying in 5 seconds...",
})
c.handleContainerEvent(Event{
Type: LogMessage,
Data: fmt.Sprintf("Waiting for the docker daemon to start, tried %d times to connect", retryCount),
})
_, err = dockerClient.ContainerList(context.Background(), types.ContainerListOptions{})
time.Sleep(time.Second * 5)
}
Expand Down

0 comments on commit 17313b7

Please sign in to comment.