Skip to content

Commit

Permalink
Merge pull request #160 from Revolyssup/panic
Browse files Browse the repository at this point in the history
fix extranous logging and URL
  • Loading branch information
Revolyssup authored Oct 7, 2022
2 parents 427ea15 + f1ccdf7 commit 3bd9646
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ func main() {
os.Exit(1)
}
// Make sure Broker has started before starting NATS client

urls := strings.Split(cfg.GetKey(config.BrokerURL), ":")
if len(urls) == 0 {
log.Info("invalid URL")
os.Exit(1)
}
pingURL := "http://" + urls[0] + pingEndpoint
for {
urls := strings.Split(config.BrokerURL, ":")
if len(urls) == 0 {
log.Info("invalid URL")
os.Exit(1)
}
pingURL := "http://" + urls[0] + pingEndpoint
resp, err := http.Get(pingURL) //remove nats port and use status port for ping
if err != nil {
log.Info("could not connect to broker: " + err.Error() + " retrying...")
time.Sleep(1 * time.Second)
continue
}
if resp.StatusCode == http.StatusOK {
break
}
log.Error(fmt.Errorf("could not recieve OK response from broker: "+pingURL, " retrying..."))
log.Info("could not recieve OK response from broker: "+pingURL, " retrying...")
time.Sleep(1 * time.Second)
}

Expand Down

0 comments on commit 3bd9646

Please sign in to comment.