Skip to content

Commit

Permalink
Merge pull request #34 from Comcast/feature/dnsReady
Browse files Browse the repository at this point in the history
make requests to insure dns is ready before preceding.
  • Loading branch information
njharter authored Jul 31, 2017
2 parents a76154b + 536b212 commit 5d21eb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/caduceus/caduceus.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ func caduceus(arguments []string) int {
return 1
}

// make sure dns is ready before preceeding
dnsReadyChan := make(chan bool, 1)
go caduceusHealth.dnsReady(selfURL.String(), dnsReadyChan)
<- dnsReadyChan
logger.Debug("DNS ready")

webhookFactory.PrepareAndStart()

logger.Info("Caduceus is up and running!")
Expand Down
18 changes: 18 additions & 0 deletions src/caduceus/caduceus_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/Comcast/webpa-common/logging"
"github.com/Comcast/webpa-common/secure"
"github.com/Comcast/webpa-common/secure/key"
"net/http"
"time"
)

Expand Down Expand Up @@ -105,6 +106,23 @@ func (ch *CaduceusHealth) IncrementBucket(inSize int) {
}
}

func (ch *CaduceusHealth) dnsReady(address string, ready chan bool) {
req, err := http.NewRequest("GET", address, nil)
if err != nil {
return
}
client := http.Client{}

var resp *http.Response
for resp == nil {
resp, err = client.Do(req)
if err == nil {
ready <- true
break
}
}
}

// Below is the struct and implementation of our worker pool factory
type WorkerPoolFactory struct {
NumWorkers int
Expand Down

0 comments on commit 5d21eb0

Please sign in to comment.