// Kick the remote container when a folder has successfully completed updating.
// This is monitored from the local syncthing server.
Kick the remote container when a folder has successfully completed updating.
This is monitored from the local syncthing server.
// Kick the remote container when a folder has successfully completed updating . // This is monitored from the local syncthing server .
func (f *Folder) hotReload() error {
	f.restartContainer = make(chan bool)
	go func() {
		tooSoon := false
		for {
			select {
			case <-f.restartContainer:
				if tooSoon {
					continue
				}
				tooSoon = true
				log.WithFields(f.ShortFields()).Info("issuing reload")
				f.Status = ServiceReloading
				if _, err := f.radarClient.Restart(
					context.Background(), &pb.ContainerPath{
						ContainerId: f.RemoteContainer.ID,
					}); err != nil {
					log.WithFields(f.RemoteContainer.Fields()).Debug(err)
					continue
				}
				log.WithFields(f.ShortFields()).Info("reloaded")
				f.Status = ServiceWatching
			case <-time.After(tooSoonReset):
				tooSoon = false
			case <-f.stop:
				return
			}
		}
	}()
	return nil
}
func ( f * Folder ) hotReload ( ) error { f . restartContainer = make ( chan bool ) go func ( ) { tooSoon := false for { select { case <- f . restartContainer : if tooSoon { continue } tooSoon = true log . WithFields ( f . ShortFields ( ) ) . Info ( " " ) f . Status = ServiceReloading if _ , err := f . radarClient . Restart ( context . Background ( ) , & pb . ContainerPath { ContainerId : f . RemoteContainer . ID , } ) ; err != nil { log . WithFields ( f . RemoteContainer . Fields ( ) ) . Debug ( err ) continue } log . WithFields ( f . ShortFields ( ) ) . Info ( " " ) f . Status = ServiceWatching case <- time . After ( tooSoonReset ) : tooSoon = false case <- f . stop : return } } } ( ) return nil }
Kick the remote container when a folder has successfully completed updating.
Kick the remote container when a folder has successfully completed updating .
// TODO: this is pretty naive, there are definite edge cases here where the // reload will happen but not actually get some files.