From 45a8a5907fe58de57ed1bac45587a5609bae0454 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Nov 2015 10:48:59 -0800 Subject: [PATCH] synced_folders/rsync: SSH control for faster rsync --- plugins/synced_folders/rsync/command/rsync_auto.rb | 3 +++ plugins/synced_folders/rsync/helper.rb | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/plugins/synced_folders/rsync/command/rsync_auto.rb b/plugins/synced_folders/rsync/command/rsync_auto.rb index 097e68cc3b9..407b7f36802 100644 --- a/plugins/synced_folders/rsync/command/rsync_auto.rb +++ b/plugins/synced_folders/rsync/command/rsync_auto.rb @@ -185,7 +185,10 @@ def callback(paths, modified, added, removed) ssh_info = opts[:machine].ssh_info begin + start = Time.now RsyncHelper.rsync_single(opts[:machine], ssh_info, opts[:opts]) + finish = Time.now + @logger.info("Time spent in rsync: #{finish-start} (in seconds)") rescue Vagrant::Errors::MachineGuestNotReady # Error communicating to the machine, probably a reload or # halt is happening. Just notify the user but don't fail out. diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index e155d61f70f..495cb7e5d95 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -66,9 +66,17 @@ def self.rsync_single(machine, ssh_info, opts) proxy_command = "-o ProxyCommand='#{ssh_info[:proxy_command]}' " end + # Create the path for the control sockets. We used to do this + # in the machine data dir but this can result in paths that are + # too long for unix domain sockets. + controlpath = File.join(Dir.tmpdir, "ssh.#{rand(1000)}") + rsh = [ "ssh -p #{ssh_info[:port]} " + proxy_command + + "-o ControlMaster=auto " + + "-o ControlPath=#{controlpath} " + + "-o ControlPersist=10m " + "-o StrictHostKeyChecking=no " + "-o IdentitiesOnly=true " + "-o UserKnownHostsFile=/dev/null",