Increase timeout for Syncthing startup.
[src/xds/xds-server.git] / main.go
diff --git a/main.go b/main.go
index 36586cf..8d49bab 100644 (file)
--- a/main.go
+++ b/main.go
@@ -132,24 +132,26 @@ func xdsApp(cliCtx *cli.Context) error {
                if err != nil {
                        return cli.NewExitError(err, 2)
                }
-               ctx.Log.Infof("Syncthing started (PID %d)", ctx.SThgCmd.Process.Pid)
+               fmt.Printf("Syncthing started (PID %d)\n", ctx.SThgCmd.Process.Pid)
 
                ctx.Log.Infof("Starting Syncthing-inotify...")
                ctx.SThgInotCmd, err = ctx.SThg.StartInotify()
                if err != nil {
                        return cli.NewExitError(err, 2)
                }
-               ctx.Log.Infof("Syncthing-inotify started (PID %d)", ctx.SThgInotCmd.Process.Pid)
+               fmt.Printf("Syncthing-inotify started (PID %d)\n", ctx.SThgInotCmd.Process.Pid)
 
                // 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--
                }
@@ -168,6 +170,10 @@ func xdsApp(cliCtx *cli.Context) error {
                }
 
                // Retrieve initial Syncthing config
+
+               // FIXME: cannot retrieve default SDK, need to save on disk or somewhere
+               // else all config to be able to restore it.
+               defaultSdk := ""
                stCfg, err := ctx.SThg.ConfigGet()
                if err != nil {
                        return cli.NewExitError(err, 2)
@@ -177,7 +183,8 @@ func xdsApp(cliCtx *cli.Context) error {
                        if relativePath == "" {
                                relativePath = stFld.RawPath
                        }
-                       newFld := xdsconfig.NewFolderConfig(stFld.ID, stFld.Label, ctx.Config.ShareRootDir, strings.Trim(relativePath, "/"))
+
+                       newFld := xdsconfig.NewFolderConfig(stFld.ID, stFld.Label, ctx.Config.ShareRootDir, strings.TrimRight(relativePath, "/"), defaultSdk)
                        ctx.Config.Folders = ctx.Config.Folders.Update(xdsconfig.FoldersConfig{newFld})
                }