vagrant-rsync-blitz 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d888bee8e4c30a23583d156de1e3cb3a59937428a25cb3a719b95796a65f67d
4
+ data.tar.gz: 6861ee4e30b00aacec05ac5238433925c687f49bcfa26d94c1c39214637c2139
5
+ SHA512:
6
+ metadata.gz: 31014b6743114f9fb94e89355a189da76f3c471ea0c75a0f396f10f926c6e6be66ea0e0a6519dad2cae8034a5e6acdfbdb59da56d1fc738f2ab13e7f14329ed2
7
+ data.tar.gz: 296c1acec090dda0cf4a17418853f3cd90ed9d4296220328fdecdcf7ab317bd2a4564238e2d70df84c76df8bf16e930767da20edbf2188fc6b8910cfb9f45b3a
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ *.swp
18
+ *.swo
19
+ example/files/*
20
+ example/vagrant/.vagrant
@@ -0,0 +1 @@
1
+ 2.6.2
@@ -0,0 +1,101 @@
1
+ # Blitz
2
+
3
+ ## 2.0.0 (Dec 01, 2020)
4
+
5
+ Hard fork and rename to `vagrant-rsync-blitz`
6
+
7
+ - Rename configuration properties
8
+ - Make default values less intrusive
9
+
10
+ ## 1.0.1 (Dec 01, 2020)
11
+
12
+ This release adds compatibility with Vagrant 2.2.10+.
13
+
14
+ FEATURES:
15
+
16
+ - Add compatibility with Vagrant 2.2.10+
17
+
18
+ # Gatling
19
+
20
+ ## 1.0.0 (June 02, 2020)
21
+
22
+ This release adds compatibility with Vagrant 2.2.5+.
23
+
24
+ Small parts of the example Vagrantfile and the Gemfile and Gemspec have also been cleaned up.
25
+
26
+ FEATURES:
27
+
28
+ - Add compatibility with Vagrant 2.2.5+. Thanks to @leejo for the PR. [GH-37]
29
+
30
+ ## 0.9.0 (June 28, 2015)
31
+
32
+ This release adds two big features: Windows support and automatic sync on startup.
33
+
34
+ It also adds the `config.gatling.rsync_on_startup` configuration option to turn automatic rsync on startup off if you
35
+ do not want it.
36
+
37
+ It also updates the Gemfile to use Vagrant 1.7.2 for development. The gem should still work with Vagrant 1.5.1+.
38
+
39
+ FEATURES:
40
+
41
+ - Add support for Windows. Thanks to @mfradcourt for wiring it up. [GH-21]
42
+ - Add automatic sync startup on `vagrant up` or `vagrant reload` if rsync folders are present. [GH-14]
43
+
44
+ ## 0.1.0 (January 04, 2015)
45
+
46
+ This release adds feature parity with Vagrant core rsync-auto by doing a sync when gatling-rsync is started.
47
+
48
+ FEATURES:
49
+
50
+ - Perform an initial rsync when the watcher starts. [GH-13]
51
+
52
+ ## 0.0.4 (August 24, 2014)
53
+
54
+ This release adds notification of time and duration of rsyncs.
55
+
56
+ It also adds the `config.gatling.time_format` configuration option to allow customization of the time format string when
57
+ time information is printed to the console.
58
+
59
+ It also updates the Gemfile to use Vagrant 1.6.4 so that I can test on Linux using the Docker provider. This should not
60
+ have any impact on using the gem with 1.5.1+ versions of Vagrant, however.
61
+
62
+ FEATURES:
63
+
64
+ - Add output to note when an rsync finishes and how long it took. [GH-7, GH-10]
65
+
66
+ BUG FIXES:
67
+
68
+ - The plugin now correctly outputs an error instead of failing to load on Vagrant versions < 1.5.1. [GH-11]
69
+
70
+ ## 0.0.3 (May 02, 2014)
71
+
72
+ Bugfix release.
73
+
74
+ BUG FIXES:
75
+
76
+ - Fix the plugin under multi-box environments. Thanks to @mattchannelgrabber. [GH-5]
77
+
78
+ ## 0.0.2 (April 27, 2014)
79
+
80
+ Bugfix release.
81
+
82
+ BUG FIXES:
83
+
84
+ - Catch ThreadErrors (this sometimes happens in practice on OS X.)
85
+ - Reflect that this plugin requires Vagrant 1.5.1+.
86
+
87
+ ## 0.0.1 (March 23, 2014)
88
+
89
+ Initial release.
90
+
91
+ FEATURES:
92
+
93
+ - Implement an rb-fsevent adapter for Mac.
94
+ - Implement an rb-inotify adapter for Linux.
95
+ - Add the `vagrant gatling-rsync-auto` command.
96
+ - Implement the first draft of a config option to allow changing the latency.
97
+
98
+ ## Backlog
99
+
100
+ - Allow configuring and running the rsync daemon to avoid SSH overhead.
101
+ - Get latency validation working.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/hashicorp/vagrant.git"
5
+ gem "rubocop", require: false
6
+ end
7
+
8
+ group :plugins do
9
+ gem "vagrant-rsync-blitz", path: "."
10
+ end
@@ -0,0 +1,141 @@
1
+ GIT
2
+ remote: https://github.com/hashicorp/vagrant.git
3
+ revision: 22795b161bf67a4c0ebbe32c9ce8777cb888c4a7
4
+ specs:
5
+ vagrant (2.2.11.dev)
6
+ bcrypt_pbkdf (~> 1.0.0)
7
+ childprocess (~> 4.0.0)
8
+ ed25519 (~> 1.2.4)
9
+ erubi
10
+ hashicorp-checkpoint (~> 0.1.5)
11
+ i18n (~> 1.8)
12
+ listen (~> 3.1)
13
+ log4r (~> 1.1.9, < 1.1.11)
14
+ mime (~> 0.4.4)
15
+ net-scp (~> 1.2.0)
16
+ net-sftp (~> 3.0)
17
+ net-ssh (~> 6.0)
18
+ rb-kqueue (~> 0.2.0)
19
+ rest-client (>= 1.6.0, < 3.0)
20
+ ruby_dep (<= 1.3.1)
21
+ rubyzip (~> 2.0)
22
+ vagrant_cloud (~> 2.0.3)
23
+ wdm (~> 0.1.0)
24
+ winrm (>= 2.3.4, < 3.0)
25
+ winrm-elevated (>= 1.2.1, < 2.0)
26
+ winrm-fs (>= 1.3.4, < 2.0)
27
+
28
+ PATH
29
+ remote: .
30
+ specs:
31
+ vagrant-rsync-blitz (2.0.0)
32
+
33
+ GEM
34
+ remote: https://rubygems.org/
35
+ specs:
36
+ ast (2.4.1)
37
+ bcrypt_pbkdf (1.0.1)
38
+ builder (3.2.4)
39
+ childprocess (4.0.0)
40
+ concurrent-ruby (1.1.7)
41
+ domain_name (0.5.20190701)
42
+ unf (>= 0.0.5, < 1.0.0)
43
+ ed25519 (1.2.4)
44
+ erubi (1.10.0)
45
+ ffi (1.13.1)
46
+ gssapi (1.3.1)
47
+ ffi (>= 1.0.1)
48
+ gyoku (1.3.1)
49
+ builder (>= 2.1.2)
50
+ hashicorp-checkpoint (0.1.5)
51
+ http-cookie (1.0.3)
52
+ domain_name (~> 0.5)
53
+ httpclient (2.8.3)
54
+ i18n (1.8.5)
55
+ concurrent-ruby (~> 1.0)
56
+ listen (3.3.3)
57
+ rb-fsevent (~> 0.10, >= 0.10.3)
58
+ rb-inotify (~> 0.9, >= 0.9.10)
59
+ little-plugger (1.1.4)
60
+ log4r (1.1.10)
61
+ logging (2.3.0)
62
+ little-plugger (~> 1.1)
63
+ multi_json (~> 1.14)
64
+ mime (0.4.4)
65
+ mime-types (3.3.1)
66
+ mime-types-data (~> 3.2015)
67
+ mime-types-data (3.2020.1104)
68
+ multi_json (1.15.0)
69
+ net-scp (1.2.1)
70
+ net-ssh (>= 2.6.5)
71
+ net-sftp (3.0.0)
72
+ net-ssh (>= 5.0.0, < 7.0.0)
73
+ net-ssh (6.1.0)
74
+ netrc (0.11.0)
75
+ nori (2.6.0)
76
+ parallel (1.20.1)
77
+ parser (2.7.2.0)
78
+ ast (~> 2.4.1)
79
+ rainbow (3.0.0)
80
+ rb-fsevent (0.10.4)
81
+ rb-inotify (0.10.1)
82
+ ffi (~> 1.0)
83
+ rb-kqueue (0.2.5)
84
+ ffi (>= 0.5.0)
85
+ regexp_parser (2.0.0)
86
+ rest-client (2.0.2)
87
+ http-cookie (>= 1.0.2, < 2.0)
88
+ mime-types (>= 1.16, < 4.0)
89
+ netrc (~> 0.8)
90
+ rexml (3.2.4)
91
+ rubocop (1.5.1)
92
+ parallel (~> 1.10)
93
+ parser (>= 2.7.1.5)
94
+ rainbow (>= 2.2.2, < 4.0)
95
+ regexp_parser (>= 2.0)
96
+ rexml
97
+ rubocop-ast (>= 1.2.0)
98
+ ruby-progressbar (~> 1.7)
99
+ unicode-display_width (>= 1.4.0, < 2.0)
100
+ rubocop-ast (1.3.0)
101
+ parser (>= 2.7.1.5)
102
+ ruby-progressbar (1.10.1)
103
+ ruby_dep (1.3.1)
104
+ rubyntlm (0.6.2)
105
+ rubyzip (2.3.0)
106
+ unf (0.1.4)
107
+ unf_ext
108
+ unf_ext (0.0.7.7)
109
+ unicode-display_width (1.7.0)
110
+ vagrant_cloud (2.0.3)
111
+ rest-client (~> 2.0.2)
112
+ wdm (0.1.1)
113
+ winrm (2.3.5)
114
+ builder (>= 2.1.2)
115
+ erubi (~> 1.8)
116
+ gssapi (~> 1.2)
117
+ gyoku (~> 1.0)
118
+ httpclient (~> 2.2, >= 2.2.0.2)
119
+ logging (>= 1.6.1, < 3.0)
120
+ nori (~> 2.0)
121
+ rubyntlm (~> 0.6.0, >= 0.6.1)
122
+ winrm-elevated (1.2.3)
123
+ erubi (~> 1.8)
124
+ winrm (~> 2.0)
125
+ winrm-fs (~> 1.0)
126
+ winrm-fs (1.3.5)
127
+ erubi (~> 1.8)
128
+ logging (>= 1.6.1, < 3.0)
129
+ rubyzip (~> 2.0)
130
+ winrm (~> 2.0)
131
+
132
+ PLATFORMS
133
+ ruby
134
+
135
+ DEPENDENCIES
136
+ rubocop
137
+ vagrant!
138
+ vagrant-rsync-blitz!
139
+
140
+ BUNDLED WITH
141
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Steven Merrill
4
+ Copyright (c) 2020 Mitchell Nemitz
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,99 @@
1
+ # vagrant-rsync-blitz
2
+
3
+ An rsync watcher for Vagrant 1.5.1+ that uses fewer host resources at the
4
+ potential cost of more rsync actions.
5
+
6
+ Forked from vagrant-gatling-rsync.
7
+
8
+ ## Getting started
9
+
10
+ To get started, you need to have Vagrant 1.5.1 installed on your Linux, Mac, or
11
+ Windows host machine. To install the plugin, use the following command.
12
+
13
+ ```bash
14
+ vagrant plugin install vagrant-rsync-blitz
15
+ ```
16
+
17
+ ## Working with this plugin
18
+
19
+ Add the following information to the Vagrantfile to set the coalescing
20
+ threshold in seconds. If you do not set it, it will default to 2.
21
+
22
+ You may also specify what
23
+ [Time.strftime](http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-strftime)
24
+ options the plugin will use when it reports on completed rsyncs. The default is
25
+ "%I:%M:%S %p".
26
+
27
+ You will also need to have at least one synced folder set to type "rsync"
28
+ to use the plugin.
29
+
30
+ ```ruby
31
+ VAGRANTFILE_API_VERSION = "2"
32
+
33
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
34
+ config.vm.box = "hashicorp/precise64"
35
+
36
+ config.vm.synced_folder "../files", "/opt/vagrant/rsynced_folder", type: "rsync",
37
+ rsync__exclude: [".git/", ".idea/"]
38
+
39
+ # Configure the window for blitz to coalesce writes
40
+ if Vagrant.has_plugin?("vagrant-rsync-blitz")
41
+ config.blitz.latency = 3
42
+ config.blitz.time_format = "%H:%M:%S"
43
+ end
44
+
45
+ # Automatically sync when machines with rsync folders come up
46
+ config.blitz.autostart = true
47
+ end
48
+ ```
49
+
50
+ With the Vagrantfile configured in this fashion, you can run the following
51
+ command to sync files.
52
+
53
+ ```bash
54
+ vagrant rsync-blitz
55
+ ```
56
+
57
+ ## This plugin
58
+
59
+ The built-in `rsync-auto` plugin sometimes uses a lot of CPU and disk I/O when
60
+ it starts up on very large rsynced directories. This plugin is designed to
61
+ work well with such large rsynced folders.
62
+
63
+ The `rsync-auto` command that ships with Vagrant 1.5+ uses the listen gem. The
64
+ Listen gem is quite thorough - it uses Celluloid to spin up an actor system
65
+ and it checks file contents on OS X to ensure that running "touch" on a file
66
+ (to do a write but not update its content) will not fire the rsync command.
67
+
68
+ The downside of using Listen is that it takes a large amount of host resources
69
+ to monitor large directory structures. This gem works well with to monitor
70
+ directories hierarchies with 10,000-100,000 files.
71
+
72
+ This gem's implementation is much closer to the underlying fsevent or inotify
73
+ APIs, which allows for higher performance.
74
+
75
+ ## Event coalescing
76
+
77
+ This plugin coalesces events for you. The default latency is 2 seconds.
78
+ It is configurable through the `config.blitz.latency` parameter.
79
+ If you specify a latency of two seconds, this plugin will not fire a
80
+ `vagrant rsync` until two contiguous seconds without file events have passed.
81
+ This will delay rsyncs from happening if many writes are happening on the host
82
+ (during a `make` or a `git clone`, for example) until the activity has leveled off.
83
+
84
+ ## Building
85
+
86
+ ```
87
+ ```
88
+
89
+ ## Authors
90
+
91
+ Steven Merrill (@stevenmerrill) originally had the idea to tap into rb-fsevent
92
+ and rb-inotify to more efficiently rsync files.
93
+
94
+ Doug Marcey (@dougmarcey) provided considerable guidance in the implementation
95
+ of the coalescing functionality and wrote the initial sketch of the Linux and
96
+ Windows adapters.
97
+
98
+ Mitchell Nemitz (@mitchellnemitz) hard forked the plugin and added quality of
99
+ life features and sane default configuration.
@@ -0,0 +1,3 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,46 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ config.vm.box = "centos/7"
9
+
10
+ config.vm.provider "docker" do |d, override|
11
+ d.image = "smerrill/vagrant-centos"
12
+ d.has_ssh = true
13
+
14
+ # This is needed if you have non-Docker provisioners in the Vagrantfile.
15
+ override.vm.box = nil
16
+ end
17
+
18
+ config.vm.provider "lxc" do |d, override|
19
+ override.vm.box = "smerrill/centos-7"
20
+ end
21
+
22
+ # When using rsync-blitz in your projects, you should wrap these configs in
23
+ # an 'if Vagrant.has_plugin?("vagrant-rsync-blitz")' test.
24
+
25
+ # Configure the window for blitz to coalesce writes.
26
+ config.blitz.latency = 1.0
27
+ config.blitz.time_format = "%H:%M:%S"
28
+
29
+ # Blitz will run `vagrant rsync-blitz` after the machines in
30
+ # your Vagrant environment start if you set this to true.
31
+ config.blitz.autostart = true
32
+
33
+ # Add a multi-box setup.
34
+ config.vm.define "rsync", primary: true do |m|
35
+ m.vm.synced_folder "../files", "/opt/vagrant/rsynced_folder", type: "rsync",
36
+ rsync__exclude: [".git/", ".idea/"]
37
+ end
38
+
39
+ config.vm.define "rsync2", primary: true do |m|
40
+ m.vm.synced_folder "../files", "/opt/vagrant/rsynced_folder", type: "rsync",
41
+ rsync__exclude: [".git/", ".idea/"]
42
+ end
43
+
44
+ config.vm.define "norsync" do |m|
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant-rsync-blitz/plugin"
2
+ require "pathname"
3
+
4
+ module VagrantPlugins
5
+ module RsyncBlitz
6
+ lib_path = Pathname.new(File.expand_path("../vagrant-rsync-blitz", __FILE__))
7
+ autoload :Errors, lib_path.join("errors")
8
+ autoload :ListenOSX, lib_path.join("listen/listenosx")
9
+ autoload :ListenLinux, lib_path.join("listen/listenlinux")
10
+ autoload :ListenWindows, lib_path.join("listen/listenwindows")
11
+
12
+ # This returns the path to the source of this plugin.
13
+ #
14
+ # @return [Pathname]
15
+ def self.source_root
16
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,47 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module RsyncBlitz
5
+ class StartupRsync
6
+ include Vagrant::Action::Builtin::MixinSyncedFolders
7
+
8
+ def initialize(app, env)
9
+ @app = app
10
+ @blitz_startup_registered = false
11
+ @rsync_folder_count = 0
12
+ end
13
+
14
+ def call(env)
15
+ folders = synced_folders(env[:machine])
16
+ @rsync_folder_count += folders[:rsync].size if folders.key?(:rsync)
17
+
18
+ @app.call(env)
19
+
20
+ # Ensure only one at_exit block is registered.
21
+ return unless @blitz_startup_registered == false
22
+
23
+ return unless env[:machine].config.blitz.autostart == true
24
+
25
+ at_exit do
26
+ unless $!.is_a?(SystemExit)
27
+ env[:ui].warn "Vagrant's startup was interrupted by an exception."
28
+ exit 1
29
+ end
30
+
31
+ exit_status = $!.status
32
+ if exit_status != 0
33
+ env[:ui].warn "The previous process exited with exit code #{exit_status}."
34
+ exit exit_status
35
+ end
36
+
37
+ # Don't run if there are no rsynced folders.
38
+ unless @rsync_folder_count == 0 then
39
+ env[:machine].env.cli("rsync-blitz")
40
+ end
41
+ end
42
+
43
+ @blitz_startup_registered = true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,162 @@
1
+ require "log4r"
2
+ require "optparse"
3
+
4
+ require "vagrant"
5
+
6
+ module VagrantPlugins
7
+ module RsyncBlitz
8
+ class RsyncBlitzAuto < Vagrant.plugin(2, :command)
9
+ # This is a sanity check to make sure no one is attempting to install
10
+ # this into an early Vagrant version.
11
+ if Vagrant::VERSION < "1.5.1"
12
+ raise Errors::Vagrant15RequiredError
13
+ end
14
+
15
+ include Vagrant::Action::Builtin::MixinSyncedFolders
16
+
17
+ def self.synopsis
18
+ "syncs rsync synced folders when folders change"
19
+ end
20
+
21
+ def execute
22
+ @logger = Log4r::Logger.new("vagrant::commands::rsync-blitz")
23
+
24
+ opts = OptionParser.new do |o|
25
+ o.banner = "Usage: vagrant rsync-blitz [vm-name]"
26
+ o.separator ""
27
+ end
28
+
29
+ # Parse the options and return if we don't have any target.
30
+ argv = parse_options(opts)
31
+ return if !argv
32
+
33
+ latency = nil
34
+
35
+ # Build up the paths that we need to listen to.
36
+ paths = {}
37
+ ignores = []
38
+ with_target_vms(argv) do |machine|
39
+ latency = machine.config.blitz.latency
40
+
41
+ folders = synced_folders(machine)[:rsync]
42
+ next if !folders || folders.empty?
43
+
44
+ # Get the SSH info for this machine so we can do an initial
45
+ # sync to the VM, just as core `vagrant rsync-auto` does.
46
+ ssh_info = machine.ssh_info
47
+ if ssh_info
48
+ machine.ui.info(I18n.t("vagrant.rsync_auto_initial"))
49
+ folders.each do |id, folder_opts|
50
+ VagrantPlugins::SyncedFolderRSync::RsyncHelper.rsync_single(machine, ssh_info, folder_opts)
51
+ end
52
+ end
53
+
54
+ folders.each do |id, folder_opts|
55
+ # If we marked this folder to not auto sync, then
56
+ # don't do it.
57
+ next if folder_opts.has_key?(:auto) && !folder_opts[:auto]
58
+
59
+ hostpath = folder_opts[:hostpath]
60
+ hostpath = File.expand_path(hostpath, machine.env.root_path)
61
+ paths[hostpath] ||= []
62
+ paths[hostpath] << {
63
+ id: id,
64
+ machine: machine,
65
+ opts: folder_opts,
66
+ }
67
+
68
+ if folder_opts[:exclude]
69
+ Array(folder_opts[:exclude]).each do |pattern|
70
+ if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new("2.2.5")
71
+ ignores << VagrantPlugins::SyncedFolderRSync::RsyncHelper.exclude_to_regexp(hostpath, pattern.to_s)
72
+ else
73
+ ignores << VagrantPlugins::SyncedFolderRSync::RsyncHelper.exclude_to_regexp(pattern.to_s)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ # Output to the user what paths we'll be watching
81
+ paths.keys.sort.each do |path|
82
+ paths[path].each do |path_opts|
83
+ path_opts[:machine].ui.info(I18n.t(
84
+ "vagrant.rsync_auto_path",
85
+ path: path.to_s,
86
+ ))
87
+ end
88
+ end
89
+
90
+ @logger.info("Listening to paths: #{paths.keys.sort.inspect}")
91
+ @logger.info("Ignoring #{ignores.length} paths:")
92
+ ignores.each do |ignore|
93
+ @logger.info(" -- #{ignore.to_s}")
94
+ end
95
+
96
+ case RUBY_PLATFORM
97
+ when /darwin/
98
+ ListenOSX.new(paths, ignores, latency, @logger, self.method(:callback)).run
99
+ when /linux/
100
+ ListenLinux.new(paths, ignores, latency, @logger, self.method(:callback)).run
101
+ when /cygwin|mswin|mingw|bccwin|wince|emx/
102
+ ListenWindows.new(paths, ignores, latency, @logger, self.method(:callback)).run
103
+ else
104
+ # @TODO: Raise this earlier?
105
+ raise Errors::OSNotSupportedError
106
+ end
107
+
108
+ 0
109
+ end
110
+
111
+ # This callback gets called when any directory changes.
112
+ def callback(paths, ignores, modified)
113
+ @logger.info("File change callback called!")
114
+ @logger.info(" - Paths: #{paths.inspect}")
115
+ @logger.info(" - Ignores: #{ignores.inspect}")
116
+ @logger.info(" - Modified: #{modified.inspect}")
117
+
118
+ tosync = []
119
+ paths.each do |hostpath, folders|
120
+ # Find out if this path should be synced
121
+ found = catch(:done) do
122
+ modified.each do |changed|
123
+ match = nil
124
+ ignores.each do |ignore|
125
+ next unless match.nil?
126
+ match = ignore.match(changed)
127
+ end
128
+
129
+ next unless match.nil?
130
+ throw :done, true if changed.start_with?(hostpath)
131
+ end
132
+
133
+ # Make sure to return false if all else fails so that we
134
+ # don't sync to this machine.
135
+ false
136
+ end
137
+
138
+ # If it should be synced, store it for later
139
+ tosync << folders if found
140
+ end
141
+
142
+ # Sync all the folders that need to be synced
143
+ tosync.each do |folders|
144
+ folders.each do |opts|
145
+ ssh_info = opts[:machine].ssh_info
146
+ do_rsync(opts[:machine], ssh_info, opts[:opts]) if ssh_info
147
+ end
148
+ end
149
+ end
150
+
151
+ def do_rsync(machine, ssh_info, opts)
152
+ start_time = Time.new
153
+ VagrantPlugins::SyncedFolderRSync::RsyncHelper.rsync_single(machine, ssh_info, opts)
154
+ end_time = Time.new
155
+ machine.ui.info(I18n.t(
156
+ "vagrant_rsync_blitz.blitz_ran",
157
+ date: end_time.strftime(machine.config.blitz.time_format),
158
+ milliseconds: (end_time - start_time) * 1000))
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,39 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module RsyncBlitz
5
+ class Config < Vagrant.plugin(2, :config)
6
+ attr_accessor :autostart
7
+ attr_accessor :latency
8
+ attr_accessor :time_format
9
+
10
+ def initialize
11
+ @autostart = UNSET_VALUE
12
+ @latency = UNSET_VALUE
13
+ @time_format = UNSET_VALUE
14
+ end
15
+
16
+ def finalize!
17
+ @autostart = false if @autostart == UNSET_VALUE
18
+ @latency = 2.0 if @latency == UNSET_VALUE
19
+ @time_format = "%I:%M:%S %p" if @time_format == UNSET_VALUE
20
+ end
21
+
22
+ def validate(machine)
23
+ errors = _detected_errors
24
+
25
+ if @latency == UNSET_VALUE
26
+ return
27
+ elsif not @latency.is_a? Numeric
28
+ @latency = 2.0
29
+ errors << "Latency must be a number, setting to 2.0"
30
+ elsif @latency < 0.2
31
+ @latency = 0.2
32
+ errors << "Latency must not be too low, setting to 0.2 seconds"
33
+ end
34
+
35
+ { "blitz" => errors }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module RsyncBlitz
5
+ module Errors
6
+ class VagrantRsyncBlitzError < Vagrant::Errors::VagrantError
7
+ error_namespace("vagrant_rsync_blitz.errors")
8
+ end
9
+
10
+ class OSNotSupportedError < VagrantRsyncBlitzError
11
+ error_key(:os_not_supported)
12
+ end
13
+
14
+ class Vagrant15RequiredError < VagrantRsyncBlitzError
15
+ error_key(:vagrant_15_required)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ require "rb-inotify"
2
+
3
+ module VagrantPlugins
4
+ module RsyncBlitz
5
+ class ListenLinux
6
+ def initialize(paths, ignores, latency, logger, callback)
7
+ @paths = paths
8
+ @ignores = ignores
9
+ @latency = latency
10
+ @logger = logger
11
+ @callback = callback
12
+ end
13
+
14
+ def run
15
+ @logger.info("Listening via: rb-inotify on Linux.")
16
+
17
+ notifier = INotify::Notifier.new
18
+ @paths.keys.each do |path|
19
+ notifier.watch(path, :modify, :create, :delete, :recursive) {}
20
+ end
21
+
22
+ loop do
23
+ directories = Set.new
24
+ begin
25
+ loop do
26
+ events = []
27
+ events = Timeout::timeout(@latency) {
28
+ notifier.read_events
29
+ }
30
+ events.each { |e| directories << e.absolute_name }
31
+ end
32
+ rescue Timeout::Error
33
+ @logger.info("Breaking out of the loop at #{Time.now.to_s}.")
34
+ end
35
+
36
+ @logger.info("Detected changes to #{directories.inspect}.") unless directories.empty?
37
+
38
+ @callback.call(@paths, @ignores, directories) unless directories.empty?
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,52 @@
1
+ require "rb-fsevent"
2
+
3
+ module VagrantPlugins
4
+ module RsyncBlitz
5
+ class ListenOSX
6
+ def initialize(paths, ignores, latency, logger, callback)
7
+ @paths = paths
8
+ @ignores = ignores
9
+ @latency = latency
10
+ @options = {
11
+ # We set this to a small value to ensure that we can coalesce the
12
+ # events together to prevent rsyncing too often under heavy write
13
+ # load.
14
+ :latency => 0.1,
15
+ :no_defer => false,
16
+ }
17
+ @logger = logger
18
+ @callback = callback
19
+ end
20
+
21
+ def run
22
+ @logger.info("Listening via: rb-fsevent on Mac OS X.")
23
+ changes = Queue.new
24
+
25
+ fsevent = FSEvent.new
26
+ fsevent.watch @paths.keys, @options do |directories|
27
+ directories.each { |d| changes << d }
28
+ end
29
+ Thread.new { fsevent.run }
30
+
31
+ loop do
32
+ directories = Set.new
33
+ begin
34
+ loop do
35
+ @logger.info("Starting the timeout at #{Time.now.to_s}.")
36
+ change = Timeout::timeout(@latency) {
37
+ changes.pop
38
+ }
39
+ directories << change unless change.nil?
40
+ end
41
+ rescue Timeout::Error, ThreadError
42
+ @logger.info("Breaking out of the loop at #{Time.now.to_s}.")
43
+ end
44
+
45
+ @logger.info("Detected changes to #{directories.inspect}.") unless directories.empty?
46
+
47
+ @callback.call(@paths, @ignores, directories) unless directories.empty?
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,45 @@
1
+ # @TODO: Note that this is entirely untested and not yet implemented.
2
+
3
+ require "wdm"
4
+
5
+ module VagrantPlugins
6
+ module RsyncBlitz
7
+ class ListenWindows
8
+ def initialize(paths, ignores, latency, logger, callback)
9
+ @paths = paths
10
+ @ignores = ignores
11
+ @latency = latency
12
+ @logger = logger
13
+ @callback = callback
14
+ end
15
+
16
+ def run
17
+ @logger.info("Listening via: WDM on Windows.")
18
+ monitor = WDM::Monitor.new
19
+ changes = Queue.new
20
+ @paths.keys.each do |path|
21
+ monitor.watch_recursively(path.dup) { |change| changes << change }
22
+ end
23
+ Thread.new { monitor.run! }
24
+
25
+ loop do
26
+ directories = Set.new
27
+ begin
28
+ loop do
29
+ change = Timeout::timeout(@latency) {
30
+ changes.pop
31
+ }
32
+ directories << change.path
33
+ end
34
+ rescue Timeout::Error
35
+ @logger.info("Breaking out of the loop at #{Time.now.to_s}.")
36
+ end
37
+
38
+ @logger.info(directories.inspect) unless directories.empty?
39
+
40
+ @callback.call(@paths, @ignores, directories) unless directories.empty?
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The vagrant-rsync-blitz plugin must be run within Vagrant."
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module RsyncBlitz
9
+ class Plugin < Vagrant.plugin(2)
10
+ name "Rsync Blitz"
11
+ description <<-DESC
12
+ Rsync large project directories to your Vagrant VM without using many resources on the host.
13
+ DESC
14
+
15
+ # This initializes the internationalization strings.
16
+ def self.setup_i18n
17
+ I18n.load_path << File.expand_path("locales/en.yml", RsyncBlitz.source_root)
18
+ I18n.reload!
19
+ end
20
+
21
+ action_hook "startup-rsync" do |hook|
22
+ setup_i18n
23
+ require_relative "action/startup_rsync"
24
+ hook.after Vagrant::Action::Builtin::SyncedFolders, StartupRsync
25
+ end
26
+
27
+ command "rsync-blitz" do
28
+ setup_i18n
29
+
30
+ require_relative "command/rsync_auto"
31
+ RsyncBlitzAuto
32
+ end
33
+
34
+ config "blitz" do
35
+ require_relative "config"
36
+ Config
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module RsyncBlitz
3
+ VERSION = "2.0.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ en:
2
+ vagrant_rsync_blitz:
3
+ blitz_ran: |-
4
+ %{date}: The rsync operation completed in %{milliseconds} milliseconds.
5
+ errors:
6
+ os_not_supported: |-
7
+ The vagrant-rsync-blitz plugin does not support your OS.
8
+ vagrant_15_required: |-
9
+ The vagrant-rsync-blitz plugin requires Vagrant 1.5.1 or newer to function.
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "vagrant-rsync-blitz/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "vagrant-rsync-blitz"
9
+ spec.version = VagrantPlugins::RsyncBlitz::VERSION
10
+ spec.authors = ["Steven Merrill", "Mitchell Nemitz"]
11
+ spec.email = ["steven.merrill@gmail.com", "mitchell.nemitz@gmail.com"]
12
+ spec.summary = %q{A lighter-weight Vagrant plugin for watching and rsyncing directories.}
13
+ spec.description = %q{The rsync-blitz plugin runs on Mac and Linux and is far less CPU-intensive than the built-in rsync-auto.}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?("example/files")}
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-rsync-blitz
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Merrill
8
+ - Mitchell Nemitz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-12-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: The rsync-blitz plugin runs on Mac and Linux and is far less CPU-intensive
43
+ than the built-in rsync-auto.
44
+ email:
45
+ - steven.merrill@gmail.com
46
+ - mitchell.nemitz@gmail.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - ".ruby-version"
53
+ - CHANGELOG.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - example/vagrant/Vagrantfile
60
+ - lib/vagrant-rsync-blitz.rb
61
+ - lib/vagrant-rsync-blitz/action/startup_rsync.rb
62
+ - lib/vagrant-rsync-blitz/command/rsync_auto.rb
63
+ - lib/vagrant-rsync-blitz/config.rb
64
+ - lib/vagrant-rsync-blitz/errors.rb
65
+ - lib/vagrant-rsync-blitz/listen/listenlinux.rb
66
+ - lib/vagrant-rsync-blitz/listen/listenosx.rb
67
+ - lib/vagrant-rsync-blitz/listen/listenwindows.rb
68
+ - lib/vagrant-rsync-blitz/plugin.rb
69
+ - lib/vagrant-rsync-blitz/version.rb
70
+ - locales/en.yml
71
+ - vagrant-rsync-blitz.gemspec
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.1.4
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A lighter-weight Vagrant plugin for watching and rsyncing directories.
95
+ test_files: []