Increase timeout for Syncthing startup. v0.0.1-alpha
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 31 May 2017 10:24:12 +0000 (12:24 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 31 May 2017 10:24:12 +0000 (12:24 +0200)
Syncthing may take more time to start for example on slow network connection.

main.go

diff --git a/main.go b/main.go
index 49f36a5..8d49bab 100644 (file)
--- a/main.go
+++ b/main.go
@@ -144,13 +144,14 @@ func xdsApp(cliCtx *cli.Context) error {
                // Establish connection with local Syncthing (retry if connection fail)
                fmt.Printf("Establishing connection with Syncthing...\n")
                time.Sleep(2 * time.Second)
-               retry := 10
+               maxRetry := 30
+               retry := maxRetry
                err = nil
                for retry > 0 {
                        if err = ctx.SThg.Connect(); err == nil {
                                break
                        }
-                       ctx.Log.Warningf("Establishing connection to Syncthing (retry %d/10)", retry)
+                       ctx.Log.Warningf("Establishing connection to Syncthing (retry %d/%d)", retry, maxRetry)
                        time.Sleep(time.Second)
                        retry--
                }