Skip to content

Commit

Permalink
Merge pull request #40 from Comcast/feature/startupTime
Browse files Browse the repository at this point in the history
Feature/startupTime
  • Loading branch information
schmidtw authored Aug 10, 2017
2 parents 43f1f6a + 568ce24 commit bd79611
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
15 changes: 12 additions & 3 deletions src/caduceus/caduceus.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func getValidator(v *viper.Viper) (validator secure.Validator, err error) {
// caduceus is the driver function for Caduceus. It performs everything main() would do,
// except for obtaining the command-line arguments (which are passed to it).
func caduceus(arguments []string) int {
totalTime := time.Now()

var (
f = pflag.NewFlagSet(applicationName, pflag.ContinueOnError)
v = viper.New()
Expand Down Expand Up @@ -212,26 +214,33 @@ func caduceus(arguments []string) int {
}

// make sure dns is ready before preceeding
logger.Debug("Reaching out to see if DNS is ready.")
now := time.Now()
dnsReadyChan := make(chan bool, 1)
go caduceusHealth.dnsReady(selfURL.String(), dnsReadyChan)
<-dnsReadyChan
logger.Debug("DNS ready")
logger.Debug("DNS is ready. elapsed time: %v", time.Since(now))

// todo: add message
webhookFactory.PrepareAndStart()

logger.Info("Caduceus is up and running!")

// Attempt to obtain the current listener list from current system without having to wait for listener reregistration.
logger.Debug("Attempting to obtain current listener list from %v", v.GetString("start.apiPath"))
now = time.Now()
startChan := make(chan webhook.Result, 1)
webhookFactory.Start.GetCurrentSystemsHooks(startChan)
var webhookStartResults webhook.Result = <-startChan
if webhookStartResults.Error != nil {
logger.Error(webhookStartResults.Error)
} else {
// todo: add message
webhookFactory.SetList(webhook.NewList(webhookStartResults.Hooks))
caduceusSenderWrapper.Update(webhookStartResults.Hooks)
}
logger.Debug("current listener retrieval, elapsed time: %v", time.Since(now))

logger.Info("Caduceus is up and running! elapsed time: %v", time.Since(totalTime))

var (
signals = make(chan os.Signal, 1)
)
Expand Down
1 change: 1 addition & 0 deletions src/caduceus/caduceus_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (ch *CaduceusHealth) dnsReady(address string, ready chan bool) {
ready <- true
break
}
time.Sleep(time.Second * 1) // wait a moment between queries
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/glide.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package: .
import:
- package: github.com/Comcast/webpa-common
version: 2a34f4bb4e58ab1b0df77cf052a1a098aec1a282
version: 2943129fb5ff4723c43aeee7e6b36b5e00e46c47
subpackages:
- concurrent
- handler
Expand Down

0 comments on commit bd79611

Please sign in to comment.