Skip to content

Commit

Permalink
fix: fix agent start/restart/loop
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Feb 22, 2020
1 parent 0365edb commit 68ea442
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions go/pkg/pwagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func Daemon(ctx context.Context, cli *client.Client, apiClient *http.Client, opt
break
}

opts.ForceRecreate = false // only do it once
opts.Cleanup = false // only do it once

time.Sleep(opts.LoopDelay)
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions go/pkg/pwagent/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,26 @@ func ensureNginxContainer(ctx context.Context, dockerClient *client.Client, opts
if err != nil {
return errcode.ErrBuildNginxContainer.Wrap(err)
}
running = true
running = false
} else {
nginxContainerID = nginxContainer.ID
running = nginxContainer.State == "running"
}

// start nginx container if needed
if running {
if !running {
err = dockerClient.ContainerStart(ctx, nginxContainerID, types.ContainerStartOptions{})
if err != nil {
return errcode.ErrStartNginxContainer.Wrap(err)
}
nginxContainer, err = checkNginxContainer(ctx, dockerClient)
if err != nil {
return errcode.ErrCheckNginxContainer.Wrap(err)
}
logger.Info("started nginx", zap.String("id", nginxContainerID))
}

// connect nginx container to proxy network
nginxContainer, err = checkNginxContainer(ctx, dockerClient)
if err != nil {
return errcode.ErrCheckNginxContainer.Wrap(err)
}
if _, found := nginxContainer.NetworkSettings.Networks[pwcompose.ProxyNetworkName]; !found {
var proxyNetworkID string
networkResources, err := dockerClient.NetworkList(ctx, types.NetworkListOptions{})
Expand Down

0 comments on commit 68ea442

Please sign in to comment.