@@ -49,8 +49,8 @@ func (cmd *ProjectSync) Commands() []cli.Command {
4949 Flags : []cli.Flag {
5050 cli.IntFlag {
5151 Name : "initial-sync-timeout" ,
52- Value : 60 ,
53- Usage : "Maximum amount of time in seconds to allow for detecting each of start of the Unison container and start of initial sync. (not needed on linux)" ,
52+ Value : 120 ,
53+ Usage : "Maximum amount of time in seconds to allow for detecting each of start of the Unison container and start of initial sync. If you encounter failures detecting initial sync increasing this value may help. Search for sync on http://docs.outrigger.sh/faq/troubleshooting/ (not needed on linux)" ,
5454 EnvVar : "RIG_PROJECT_SYNC_TIMEOUT" ,
5555 },
5656 // Arbitrary sleep length but anything less than 3 wasn't catching
@@ -119,20 +119,22 @@ func (cmd *ProjectSync) RunStart(ctx *cli.Context) error {
119119
120120// StartUnisonSync will create and launch the volumes and containers on systems that need/support Unison
121121func (cmd * ProjectSync ) StartUnisonSync (ctx * cli.Context , volumeName string , config * ProjectConfig , workingDir string ) error {
122+ cmd .out .Spin ("Starting Outrigger Filesync (unison)..." )
123+
122124 // Ensure the processes can handle a large number of watches
123125 if err := cmd .machine .SetSysctl ("fs.inotify.max_user_watches" , maxWatches ); err != nil {
124126 cmd .Failure (fmt .Sprintf ("Failure configuring file watches on Docker Machine: %v" , err ), "INOTIFY-WATCH-FAILURE" , 12 )
125127 }
126128
127- cmd .out .Channel . Info . Printf ("Starting sync volume: %s" , volumeName )
129+ cmd .out .SpinWithVerbose ("Starting sync volume: %s" , volumeName )
128130 if err := util .Command ("docker" , "volume" , "create" , volumeName ).Run (); err != nil {
129131 return cmd .Failure (fmt .Sprintf ("Failed to create sync volume: %s" , volumeName ), "VOLUME-CREATE-FAILED" , 13 )
130132 }
131-
132- cmd .out .Info ( "Starting Unison container" )
133+ cmd . out . Info ( "Sync volume '%s' created" , volumeName )
134+ cmd .out .SpinWithVerbose ( fmt . Sprintf ( "Starting sync container: %s (same name)" , volumeName ) )
133135 unisonMinorVersion := cmd .GetUnisonMinorVersion ()
134136
135- cmd .out .Channel . Verbose . Printf ("Local Unison version for compatibilty: %s" , unisonMinorVersion )
137+ cmd .out .Verbose ("Local Unison version for compatibilty: %s" , unisonMinorVersion )
136138 util .Command ("docker" , "container" , "stop" , volumeName ).Run ()
137139 containerArgs := []string {
138140 "container" , "run" , "--detach" , "--rm" ,
@@ -151,8 +153,8 @@ func (cmd *ProjectSync) StartUnisonSync(ctx *cli.Context, volumeName string, con
151153 if err != nil {
152154 return cmd .Failure (err .Error (), "SYNC-INIT-FAILED" , 13 )
153155 }
154-
155- cmd .out .Info ("Initializing sync" )
156+ cmd . out . Info ( "Sync container '%s' started" , volumeName )
157+ cmd .out .SpinWithVerbose ("Initializing file sync... " )
156158
157159 // Determine the location of the local Unison log file.
158160 var logFile = fmt .Sprintf ("%s.log" , volumeName )
@@ -179,7 +181,7 @@ func (cmd *ProjectSync) StartUnisonSync(ctx *cli.Context, volumeName string, con
179181 unisonArgs = append (unisonArgs , "-ignore" , ignore )
180182 }
181183 }
182- cmd . out . Verbose ( "Unison Args: %s" , strings . Join ( unisonArgs [:], " " ))
184+
183185 /* #nosec */
184186 command := exec .Command ("unison" , unisonArgs ... )
185187 command .Dir = workingDir
@@ -192,12 +194,14 @@ func (cmd *ProjectSync) StartUnisonSync(ctx *cli.Context, volumeName string, con
192194 return cmd .Failure (err .Error (), "UNISON-SYNC-FAILED" , 13 )
193195 }
194196
197+ cmd .out .Info ("Watch unison process activities in the sync log: %s" , logFile )
198+
195199 return cmd .Success ("Unison sync started successfully" )
196200}
197201
198202// SetupBindVolume will create minimal Docker Volumes for systems that have native container/volume support
199203func (cmd * ProjectSync ) SetupBindVolume (volumeName string , workingDir string ) error {
200- cmd .out .Info ("Starting local bind volume: %s" , volumeName )
204+ cmd .out .SpinWithVerbose ("Starting local bind volume: %s" , volumeName )
201205 util .Command ("docker" , "volume" , "rm" , volumeName ).Run ()
202206
203207 volumeArgs := []string {
@@ -220,6 +224,7 @@ func (cmd *ProjectSync) RunStop(ctx *cli.Context) error {
220224 if runtime .GOOS == "linux" {
221225 return cmd .Success ("No Unison container to stop, using local bind volume" )
222226 }
227+ cmd .out .Spin (fmt .Sprintf ("Stopping Unison container" ))
223228
224229 cmd .Config = NewProjectConfig ()
225230 if cmd .Config .NotEmpty () {
@@ -238,7 +243,7 @@ func (cmd *ProjectSync) RunStop(ctx *cli.Context) error {
238243 return cmd .Failure (err .Error (), "SYNC-CONTAINER-FAILURE" , 13 )
239244 }
240245
241- return cmd .Success (fmt .Sprintf ("Unison container %s stopped" , volumeName ))
246+ return cmd .Success (fmt .Sprintf ("Unison container '%s' stopped" , volumeName ))
242247}
243248
244249// GetVolumeName will find the volume name through a variety of fall backs
@@ -283,7 +288,7 @@ func (cmd *ProjectSync) LoadComposeFile() (*ComposeFile, error) {
283288// when compiled without -cgo this executable will not use the native mac dns resolution
284289// which is how we have configured dnsdock to provide names for containers.
285290func (cmd * ProjectSync ) WaitForUnisonContainer (containerName string , timeoutSeconds int ) (string , error ) {
286- cmd .out .Info ( "Waiting for container to start" )
291+ cmd .out .SpinWithVerbose ( "Sync container '%s' started , waiting for unison server process..." , containerName )
287292
288293 var timeoutLoopSleep = time .Duration (100 ) * time .Millisecond
289294 // * 10 here because we loop once every 100 ms and we want to get to seconds
@@ -303,7 +308,7 @@ func (cmd *ProjectSync) WaitForUnisonContainer(containerName string, timeoutSeco
303308 return ip , nil
304309 }
305310
306- cmd .out .Info ("Failure: %v" , err )
311+ cmd .out .SpinWithVerbose ("Failure: %v" , err )
307312 time .Sleep (timeoutLoopSleep )
308313 }
309314
@@ -313,12 +318,12 @@ func (cmd *ProjectSync) WaitForUnisonContainer(containerName string, timeoutSeco
313318// WaitForSyncInit will wait for the local unison process to finish initializing
314319// when the log file exists and has stopped growing in size
315320func (cmd * ProjectSync ) WaitForSyncInit (logFile string , workingDir string , timeoutSeconds int , syncWaitSeconds int ) error {
316- cmd .out .Info ("Waiting for initial sync detection" )
321+ cmd .out .SpinWithVerbose ("Waiting for initial sync detection... " )
317322
318323 // The use of os.Stat below is not subject to our working directory configuration,
319324 // so to ensure we can stat the log file we convert it to an absolute path.
320325 if logFilePath , err := util .AbsJoin (workingDir , logFile ); err != nil {
321- cmd .out .Info (err .Error ())
326+ cmd .out .Error (err .Error ())
322327 } else {
323328 // Create a temp file to cause a sync action
324329 var tempFile = ".rig-check-sync-start"
@@ -333,32 +338,29 @@ func (cmd *ProjectSync) WaitForSyncInit(logFile string, workingDir string, timeo
333338 var timeoutLoops = timeoutSeconds * 10
334339 var statSleep = time .Duration (syncWaitSeconds ) * time .Second
335340 for i := 1 ; i <= timeoutLoops ; i ++ {
336- if i % 10 == 0 {
337- os .Stdout .WriteString ("." )
338- }
339-
340341 statInfo , err := os .Stat (logFilePath )
341342 if err == nil {
342- os . Stdout . WriteString ( " initial sync detected\n " )
343+ cmd . out . Info ( "Initial sync detected" )
343344
344- cmd .out .Info ("Waiting for initial sync to finish" )
345+ cmd .out .SpinWithVerbose ("Waiting for initial sync to finish" )
345346 // Initialize at -2 to force at least one loop
346347 var lastSize = int64 (- 2 )
347348 for lastSize != statInfo .Size () {
348- os .Stdout .WriteString ("." )
349349 time .Sleep (statSleep )
350350 lastSize = statInfo .Size ()
351351 if statInfo , err = os .Stat (logFilePath ); err != nil {
352- cmd .out .Info (err .Error ())
352+ cmd .out .Error (err .Error ())
353353 lastSize = - 1
354354 }
355355 }
356- os . Stdout . WriteString ( " done \n " )
356+
357357 // Remove the temp file, waiting until after sync so spurious
358358 // failure message doesn't show in log
359359 if err := util .RemoveFile (tempFile , workingDir ); err != nil {
360360 cmd .out .Warning ("Could not remove the temporary file: %s: %s" , tempFile , err .Error ())
361361 }
362+
363+ cmd .out .Info ("File sync completed" )
362364 return nil
363365 }
364366
@@ -373,6 +375,7 @@ func (cmd *ProjectSync) WaitForSyncInit(logFile string, workingDir string, timeo
373375 }
374376 }
375377
378+ cmd .out .Error ("Initial sync detection failed, this could indicate a need to increase the initial-sync-timeout. See rig project sync --help" )
376379 return fmt .Errorf ("Failed to detect start of initial sync" )
377380}
378381
0 commit comments