Skip to content

Commit

Permalink
[worker] retry registration
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Jun 17, 2020
1 parent 45e5d90 commit 85b2105
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,17 @@ func (w *Worker) registorWorker() {
for _, root := range w.cfg.Manager.APIBaseList() {
url := fmt.Sprintf("%s/workers", root)
logger.Debugf("register on manager url: %s", url)
if _, err := PostJSON(url, msg, w.httpClient); err != nil {
logger.Errorf("Failed to register worker")
for retry := 10; retry > 0; {
if _, err := PostJSON(url, msg, w.httpClient); err != nil {
logger.Errorf("Failed to register worker")
retry--
if retry > 0 {
time.Sleep(1 * time.Second)
logger.Noticef("Retrying... (%d)", retry)
}
} else {
break
}
}
}
}
Expand Down

0 comments on commit 85b2105

Please sign in to comment.