Skip to content

Commit

Permalink
nodecontainer: add sleep between ping requests
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarsa committed Jul 25, 2016
1 parent 873746a commit 58af52a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions provision/docker/nodecontainer/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ func (t *runBs) Name() string {
}

func (t *runBs) Run(job monsterqueue.Job) {
_, err := InitializeBS()
if err != nil {
job.Error(err)
return
}
params := job.Parameters()
dockerEndpoint := params["endpoint"].(string)
err := t.waitDocker(dockerEndpoint)
err = t.waitDocker(dockerEndpoint)
if err != nil {
job.Error(err)
return
Expand Down Expand Up @@ -77,19 +82,19 @@ func (t *runBs) waitDocker(endpoint string) error {
exit := make(chan struct{})
go func() {
for {
err := client.Ping()
if err == nil {
pong <- nil
return
}
if e, ok := err.(*docker.Error); ok && e.Status > 499 {
pong <- err
return
}
select {
case <-exit:
return
default:
err := client.Ping()
if err == nil {
pong <- nil
return
}
if e, ok := err.(*docker.Error); ok && e.Status > 499 {
pong <- err
return
}
case <-time.After(time.Second):
}
}
}()
Expand Down

0 comments on commit 58af52a

Please sign in to comment.