Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
Add retry to wait for server being up before starting login flow
Browse files Browse the repository at this point in the history
[Created using GitHub CoPilot]
  • Loading branch information
lennart-land committed Jan 8, 2025
1 parent d6a3ee4 commit 41da821
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions register.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import (
"time"
)

var (
maxTries = 60
tries = 0
)

func main() {
log.Printf("Trying to register server")
serverUrl := os.Args[1]
username := os.Args[2]
password := os.Args[3]
Expand Down Expand Up @@ -57,6 +63,16 @@ func getChromeDPContext() context.Context {
}

func login(ctx context.Context, serverUrl string, username string, password string, serverName string) {
for tries <= maxTries {
err := chromedp.Run(ctx,
chromedp.Navigate(serverUrl))
if err == nil {
break
}
time.Sleep(2 * time.Second)
tries++
}

err := chromedp.Run(ctx,
chromedp.Navigate(serverUrl),
chromedp.Click(`.btn`, chromedp.NodeVisible, chromedp.ByQuery),
Expand All @@ -78,6 +94,7 @@ func login(ctx context.Context, serverUrl string, username string, password stri
if err != nil {
log.Fatalf("Error logging in and selecting server: %s", err)
}

}

func selectCorrectServerAndConfirm(ctx context.Context, serverName string) {
Expand Down

0 comments on commit 41da821

Please sign in to comment.