command/rsync-auto: add --poll flag [GH-4392]

This commit is contained in:
Mitchell Hashimoto 2014-08-31 09:54:37 -07:00
parent de71e269fa
commit a54f2dc539
3 changed files with 17 additions and 1 deletions

View File

@ -19,6 +19,7 @@ IMPROVEMENTS:
- commands/plugin: Better error output is shown when plugin installation - commands/plugin: Better error output is shown when plugin installation
fails. fails.
- commands/reload: show post up messsage [GH-4168] - commands/reload: show post up messsage [GH-4168]
- commands/rsync-auto: Add `--poll` flag. [GH-4392]
- communicators/winrm: Show stdout/stderr if command fails. [GH-4094] - communicators/winrm: Show stdout/stderr if command fails. [GH-4094]
- guests/nixos: Added better NFS support. [GH-3983] - guests/nixos: Added better NFS support. [GH-3983]
- providers/hyperv: Accept VHD disk format. [GH-4208] - providers/hyperv: Accept VHD disk format. [GH-4208]

View File

@ -28,9 +28,16 @@ module VagrantPlugins
def execute def execute
@logger = Log4r::Logger.new("vagrant::commands::rsync-auto") @logger = Log4r::Logger.new("vagrant::commands::rsync-auto")
options = {}
opts = OptionParser.new do |o| opts = OptionParser.new do |o|
o.banner = "Usage: vagrant rsync-auto [vm-name]" o.banner = "Usage: vagrant rsync-auto [vm-name]"
o.separator "" o.separator ""
o.separator "Options:"
o.separator ""
o.on("--[no-]poll", "Force polling filesystem (slow)") do |poll|
options[:poll] = poll
end
end end
# Parse the options and return if we don't have any target. # Parse the options and return if we don't have any target.
@ -106,7 +113,8 @@ module VagrantPlugins
end end
@logger.info("Listening via: #{Listen::Adapter.select.inspect}") @logger.info("Listening via: #{Listen::Adapter.select.inspect}")
callback = method(:callback).to_proc.curry[paths] callback = method(:callback).to_proc.curry[paths]
listener = Listen.to(*paths.keys, ignore: ignores, &callback) listopts = { ignore: ignores, force_polling: !!opts[:poll] }
listener = Listen.to(*paths.keys, listopts, &callback)
# Create the callback that lets us know when we've been interrupted # Create the callback that lets us know when we've been interrupted
queue = Queue.new queue = Queue.new

View File

@ -15,6 +15,13 @@ not exit until an interrupt is received.
The change detection is optimized to use platform-specific APIs to listen The change detection is optimized to use platform-specific APIs to listen
for filesystem changes, and does not simply poll the directory. for filesystem changes, and does not simply poll the directory.
## Options
* `--[no-]poll` - Force Vagrant to watch for changes using filesystem
polling instead of filesystem events. This is required for some filesystems
that don't support events. Warning: enabling this will make `rsync-auto`
_much_ slower. By default, polling is disabled.
## Machine State Changes ## Machine State Changes
The `rsync-auto` command does not currently handle machine state changes The `rsync-auto` command does not currently handle machine state changes