vagrant-gatling-rsync 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.txt +16 -0
- data/Gemfile +14 -0
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/Rakefile +1 -0
- data/example/files/.gitkeep +1 -0
- data/example/vagrant/Vagrantfile +19 -0
- data/lib/vagrant-gatling-rsync/command/rsync_auto.rb +130 -0
- data/lib/vagrant-gatling-rsync/config.rb +36 -0
- data/lib/vagrant-gatling-rsync/errors.rb +19 -0
- data/lib/vagrant-gatling-rsync/listen/listenlinux.rb +44 -0
- data/lib/vagrant-gatling-rsync/listen/listenosx.rb +53 -0
- data/lib/vagrant-gatling-rsync/listen/listenwindows.rb +33 -0
- data/lib/vagrant-gatling-rsync/plugin.rb +40 -0
- data/lib/vagrant-gatling-rsync/version.rb +5 -0
- data/lib/vagrant-gatling-rsync.rb +25 -0
- data/locales/en.yml +8 -0
- data/vagrant-gatling-rsync.gemspec +25 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d981cfb603768c87a0a307b415b32acf4fdacc27
|
4
|
+
data.tar.gz: 7517d55a2e0be0a9d6fc04c7ae60c15262ebc82d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e0938d9cc6f4e67da39c1865c004b348a7ef03451ed8b93086af4dff9706101dee20a5313c4006153803588edd4def025b538a2c0fb9e1779404ad880dfb992
|
7
|
+
data.tar.gz: 176593bea18b5cc114ebd0f9ce944ccfe7c7438beb128ea738e770056ee38cc0301ede1641bfcacbcf339ea599008cc8d159f26396dda8a55cdac798692fdce6
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.swp
|
19
|
+
*.swo
|
20
|
+
example/files/*
|
21
|
+
example/vagrant/.vagrant
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/CHANGELOG.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## 0.0.1 (March 23, 2014)
|
2
|
+
|
3
|
+
Initial release.
|
4
|
+
|
5
|
+
FEATURES:
|
6
|
+
|
7
|
+
- Implement an rb-fsevent adapter for Mac.
|
8
|
+
- Implement an rb-inotify adapter for Linux.
|
9
|
+
- Add the `vagrant gatling-rsync-auto` command.
|
10
|
+
- Implement the first draft of a config option to allow changing the latency.
|
11
|
+
|
12
|
+
## Backlog
|
13
|
+
|
14
|
+
- Test and release the Windows adapter.
|
15
|
+
- Allow configuring and running the rsync daemon to avoid SSH overhead.
|
16
|
+
- Get latency validation working.
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in vagrant-gatling-rsync.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :tag => 'v1.5.1'
|
8
|
+
gem "pry"
|
9
|
+
end
|
10
|
+
|
11
|
+
group :plugins do
|
12
|
+
gem "vagrant-gatling-rsync", path: "."
|
13
|
+
end
|
14
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Steven Merrill
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# vagrant-gatling-rsync
|
2
|
+
|
3
|
+
An rsync watcher for Vagrant 1.5+ that uses fewer host resources at the
|
4
|
+
potential cost of more rsync actions.
|
5
|
+
|
6
|
+
## Authors
|
7
|
+
|
8
|
+
Steven Merrill (@stevenmerrill) originally had the idea to tap into rb-fsevent
|
9
|
+
and rb-inotify to more efficiently rsync files.
|
10
|
+
|
11
|
+
Doug Marcey (@dougmarcey) provided considerable guidance in the implementation
|
12
|
+
of the coalescing functionality and wrote the initial sketch of the Linux and
|
13
|
+
Windows adapters.
|
14
|
+
|
15
|
+
## Why "gatling"?
|
16
|
+
|
17
|
+
The gatling gun was the first gun capable of firing continuously.
|
18
|
+
|
19
|
+
## This plugin
|
20
|
+
|
21
|
+
The built-in rsync-auto plugin sometimes uses a lot of CPU and disk I/O when
|
22
|
+
it starts up on very large rsynced directories. This plugin is designed to
|
23
|
+
work well with such large rsynced folders.
|
24
|
+
|
25
|
+
The rsync-auto command that ships with Vagrant 1.5 uses the listen gem. The
|
26
|
+
Listen gem is quite thorough - it uses Celluloid to spin up an actor system
|
27
|
+
and it checks file contents on OS X to ensure that running "touch" on a file
|
28
|
+
(to do a write but not update its content) will not fire the rsync command.
|
29
|
+
|
30
|
+
The downside of using Listen is that it takes a large amount of host resources
|
31
|
+
to monitor large directory structures. This gem works well with to monitor
|
32
|
+
directories hierarchies with 10,000-100,000 files.
|
33
|
+
|
34
|
+
This gem's implementation is much closer to the underlying fsevent or inotify
|
35
|
+
APIs, which allows for higher performance.
|
36
|
+
|
37
|
+
## Event coalescing
|
38
|
+
|
39
|
+
This plugin also coalesces events for you. The default latency is 1.5 seconds.
|
40
|
+
(This will be a configurable option in future versions.) If you specify a
|
41
|
+
latency of two seconds, this plugin will not fire a `vagrant rsync` until two
|
42
|
+
contiguous seconds without file events have passed. This will delay rsyncs from
|
43
|
+
happening if many writes are happening on the host (during a `make` or a
|
44
|
+
`git clone`, for example) until the activity has leveled off.
|
45
|
+
|
46
|
+
## Working with this plugin
|
47
|
+
|
48
|
+
Add the following information to the Vagrantfile to set the coalescing
|
49
|
+
threshold in seconds. If you do not set it, it will default to 1.5.
|
50
|
+
|
51
|
+
You will also need to have at least one synced folder set to type "rsync"
|
52
|
+
to use the plugin.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
VAGRANTFILE_API_VERSION = "2"
|
56
|
+
|
57
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
58
|
+
config.vm.box = "hashicorp/precise64"
|
59
|
+
|
60
|
+
config.vm.synced_folder "../files", "/opt/vagrant/rsynced_folder", type: "rsync",
|
61
|
+
rsync__exclude: [".git/", ".idea/"]
|
62
|
+
|
63
|
+
# Configure the window for gatling to coalesce writes.
|
64
|
+
config.gatling.latency = 2.5
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
With the Vagrantfile configured in this fashion, you can run the following
|
69
|
+
command to sync files.
|
70
|
+
|
71
|
+
```bash
|
72
|
+
vagrant gatling-rsync-auto
|
73
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1 @@
|
|
1
|
+
This file only exists to keep this directory in git.
|
@@ -0,0 +1,19 @@
|
|
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 = "hashicorp/precise64"
|
9
|
+
|
10
|
+
# Share an additional folder to the guest VM. The first argument is
|
11
|
+
# the path on the host to the actual folder. The second argument is
|
12
|
+
# the path on the guest to mount the folder. And the optional third
|
13
|
+
# argument is a set of non-required options.
|
14
|
+
config.vm.synced_folder "../files", "/opt/vagrant/rsynced_folder", type: "rsync",
|
15
|
+
rsync__exclude: [".git/", ".idea/"]
|
16
|
+
|
17
|
+
# Configure the window for gatling to coalesce writes.
|
18
|
+
config.gatling.latency = 2.5
|
19
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "optparse"
|
3
|
+
|
4
|
+
require "vagrant"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module GatlingRsync
|
8
|
+
class GatlingRsyncAuto < Vagrant.plugin(2, :command)
|
9
|
+
include Vagrant::Action::Builtin::MixinSyncedFolders
|
10
|
+
|
11
|
+
def self.synopsis
|
12
|
+
"syncs rsync synced folders when folders change"
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
@logger = Log4r::Logger.new("vagrant::commands::gatling-rsync-auto")
|
17
|
+
|
18
|
+
opts = OptionParser.new do |o|
|
19
|
+
o.banner = "Usage: vagrant gatling-rsync-auto [vm-name]"
|
20
|
+
o.separator ""
|
21
|
+
end
|
22
|
+
|
23
|
+
# Parse the options and return if we don't have any target.
|
24
|
+
argv = parse_options(opts)
|
25
|
+
return if !argv
|
26
|
+
|
27
|
+
latency = nil
|
28
|
+
|
29
|
+
# Build up the paths that we need to listen to.
|
30
|
+
paths = {}
|
31
|
+
ignores = []
|
32
|
+
with_target_vms(argv) do |machine|
|
33
|
+
latency = machine.config.gatling.latency
|
34
|
+
|
35
|
+
folders = synced_folders(machine)[:rsync]
|
36
|
+
next if !folders || folders.empty?
|
37
|
+
|
38
|
+
folders.each do |id, folder_opts|
|
39
|
+
# If we marked this folder to not auto sync, then
|
40
|
+
# don't do it.
|
41
|
+
next if folder_opts.has_key?(:auto) && !folder_opts[:auto]
|
42
|
+
|
43
|
+
hostpath = folder_opts[:hostpath]
|
44
|
+
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
45
|
+
paths[hostpath] ||= []
|
46
|
+
paths[hostpath] << {
|
47
|
+
id: id,
|
48
|
+
machine: machine,
|
49
|
+
opts: folder_opts,
|
50
|
+
}
|
51
|
+
|
52
|
+
if folder_opts[:exclude]
|
53
|
+
Array(folder_opts[:exclude]).each do |pattern|
|
54
|
+
ignores << VagrantPlugins::SyncedFolderRSync::RsyncHelper.exclude_to_regexp(hostpath, pattern.to_s)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Output to the user what paths we'll be watching
|
61
|
+
paths.keys.sort.each do |path|
|
62
|
+
paths[path].each do |path_opts|
|
63
|
+
path_opts[:machine].ui.info(I18n.t(
|
64
|
+
"vagrant.rsync_auto_path",
|
65
|
+
path: path.to_s,
|
66
|
+
))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
@logger.info("Listening to paths: #{paths.keys.sort.inspect}")
|
71
|
+
@logger.info("Ignoring #{ignores.length} paths:")
|
72
|
+
ignores.each do |ignore|
|
73
|
+
@logger.info(" -- #{ignore.to_s}")
|
74
|
+
end
|
75
|
+
|
76
|
+
case RUBY_PLATFORM
|
77
|
+
when /darwin/
|
78
|
+
ListenOSX.new(paths, ignores, latency, @logger, self.method(:callback)).run
|
79
|
+
when /linux/
|
80
|
+
ListenLinux.new(paths, ignores, latency, @logger, self.method(:callback)).run
|
81
|
+
else
|
82
|
+
# @TODO: Raise this earlier?
|
83
|
+
raise Errors::OnlyOSXLinuxSupportError
|
84
|
+
end
|
85
|
+
|
86
|
+
0
|
87
|
+
end
|
88
|
+
|
89
|
+
# This callback gets called when any directory changes.
|
90
|
+
def callback(paths, ignores, modified)
|
91
|
+
@logger.info("File change callback called!")
|
92
|
+
@logger.info(" - Paths: #{paths.inspect}")
|
93
|
+
@logger.info(" - Ignores: #{ignores.inspect}")
|
94
|
+
@logger.info(" - Modified: #{modified.inspect}")
|
95
|
+
|
96
|
+
tosync = []
|
97
|
+
paths.each do |hostpath, folders|
|
98
|
+
# Find out if this path should be synced
|
99
|
+
found = catch(:done) do
|
100
|
+
modified.each do |changed|
|
101
|
+
match = nil
|
102
|
+
ignores.each do |ignore|
|
103
|
+
next unless match.nil?
|
104
|
+
match = ignore.match(changed)
|
105
|
+
end
|
106
|
+
|
107
|
+
next unless match.nil?
|
108
|
+
throw :done, true if changed.start_with?(hostpath)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Make sure to return false if all else fails so that we
|
112
|
+
# don't sync to this machine.
|
113
|
+
false
|
114
|
+
end
|
115
|
+
|
116
|
+
# If it should be synced, store it for later
|
117
|
+
tosync << folders if found
|
118
|
+
end
|
119
|
+
|
120
|
+
# Sync all the folders that need to be synced
|
121
|
+
tosync.each do |folders|
|
122
|
+
folders.each do |opts|
|
123
|
+
ssh_info = opts[:machine].ssh_info
|
124
|
+
VagrantPlugins::SyncedFolderRSync::RsyncHelper.rsync_single(opts[:machine], ssh_info, opts[:opts])
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GatlingRsync
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
attr_accessor :latency
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@latency = UNSET_VALUE
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@latency = 1.5 if @latency == UNSET_VALUE
|
14
|
+
end
|
15
|
+
|
16
|
+
# @TODO: This does not appear to be called.
|
17
|
+
def validate(machine)
|
18
|
+
errors = _detected_errors
|
19
|
+
|
20
|
+
if @latency == UNSET_VALUE
|
21
|
+
return
|
22
|
+
elsif not @latency.is_a? Numeric
|
23
|
+
@latency = 1.5
|
24
|
+
# @TODO: Translate.
|
25
|
+
errors << "The latency must be set to a number. Substituting 1.5 as a value."
|
26
|
+
elsif @latency < 0.2
|
27
|
+
@latency = 0.2
|
28
|
+
# @TODO: Translate.
|
29
|
+
errors << "The latency may not be below 0.2 seconds."
|
30
|
+
end
|
31
|
+
|
32
|
+
{ "gatling" => errors }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GatlingRsync
|
5
|
+
module Errors
|
6
|
+
class VagrantGatlingRsyncError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_gatling_rsync.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class OnlyOSXLinuxSupportError < VagrantGatlingRsyncError
|
11
|
+
error_key(:only_osx_linux_support)
|
12
|
+
end
|
13
|
+
|
14
|
+
class Vagrant15RequiredError < VagrantGatlingRsyncError
|
15
|
+
error_key(:vagrant_15_required)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "rb-inotify"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GatlingRsync
|
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
|
+
while true do
|
23
|
+
directories = Set.new
|
24
|
+
begin
|
25
|
+
while true 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
|
44
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "rb-fsevent"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GatlingRsync
|
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
|
+
while true do
|
32
|
+
directories = Set.new
|
33
|
+
begin
|
34
|
+
while true 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
|
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
|
53
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# @TODO: Note that this is entirely untested and not yet implemented.
|
2
|
+
|
3
|
+
require "timeout"
|
4
|
+
require "thread"
|
5
|
+
|
6
|
+
paths = {"/path/to/a/directory" => {}}
|
7
|
+
latency = 2
|
8
|
+
|
9
|
+
monitor = WDM::Monitor.new
|
10
|
+
changes = Queue.new
|
11
|
+
paths.keys.each do |path|
|
12
|
+
monitor.watch_recursively(path) { |change| changes << change }
|
13
|
+
end
|
14
|
+
Thread.new { monitor.run! }
|
15
|
+
|
16
|
+
while true do
|
17
|
+
directories = Set.new
|
18
|
+
begin
|
19
|
+
while true do
|
20
|
+
change = Timeout::timeout(latency) {
|
21
|
+
changes.pop
|
22
|
+
}
|
23
|
+
directories << change.path
|
24
|
+
end
|
25
|
+
rescue Timeout::Error
|
26
|
+
@logger.info("Breaking out of the loop at #{Time.now.to_s}.")
|
27
|
+
end
|
28
|
+
|
29
|
+
@logger.info(directories.inspect) unless directories.empty?
|
30
|
+
|
31
|
+
#@callback.call(paths, ignores, directories) unless directories.empty?
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant gatling rsync plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.5.0"
|
10
|
+
raise Errors::Vagrant15RequiredError
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module GatlingRsync
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "Gatling Rsync"
|
17
|
+
description <<-DESC
|
18
|
+
Rsync large project directories to your Vagrant VM without using many resources on the host.
|
19
|
+
DESC
|
20
|
+
|
21
|
+
# This initializes the internationalization strings.
|
22
|
+
def self.setup_i18n
|
23
|
+
I18n.load_path << File.expand_path("locales/en.yml", GatlingRsync.source_root)
|
24
|
+
I18n.reload!
|
25
|
+
end
|
26
|
+
|
27
|
+
command "gatling-rsync-auto" do
|
28
|
+
setup_i18n
|
29
|
+
|
30
|
+
require_relative "command/rsync_auto"
|
31
|
+
GatlingRsyncAuto
|
32
|
+
end
|
33
|
+
|
34
|
+
config "gatling" do
|
35
|
+
require_relative "config"
|
36
|
+
Config
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file is required because Vagrant's plugin system expects
|
2
|
+
# a eponymous ruby file matching the rubygem.
|
3
|
+
#
|
4
|
+
# So this gem is called 'vagrant-gatling-rsync' and thus vagrant tries
|
5
|
+
# to require "vagrant-gatling-rsync"
|
6
|
+
|
7
|
+
require "vagrant-gatling-rsync/plugin"
|
8
|
+
|
9
|
+
require "pathname"
|
10
|
+
|
11
|
+
module VagrantPlugins
|
12
|
+
module GatlingRsync
|
13
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-gatling-rsync", __FILE__))
|
14
|
+
autoload :Errors, lib_path.join("errors")
|
15
|
+
autoload :ListenOSX, lib_path.join("listen/listenosx")
|
16
|
+
autoload :ListenLinux, lib_path.join("listen/listenlinux")
|
17
|
+
|
18
|
+
# This returns the path to the source of this plugin.
|
19
|
+
#
|
20
|
+
# @return [Pathname]
|
21
|
+
def self.source_root
|
22
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-gatling-rsync/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-gatling-rsync"
|
8
|
+
spec.version = VagrantPlugins::GatlingRsync::VERSION
|
9
|
+
spec.authors = ["Steven Merrill"]
|
10
|
+
spec.email = ["steven.merrill@gmail.com"]
|
11
|
+
spec.summary = %q{A lighter-weight Vagrant plugin for watching and rsyncing directories.}
|
12
|
+
spec.description = %q{The gatling-rsync plugin run on Mac (and soon on Linux) and is far less CPU-intensive than the built-in 'vagrant rsync-auto' plugin, at the cost of possibly rsyncing more often.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# @TODO: Remove example files from the built gem.
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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 "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-gatling-rsync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Merrill
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: The gatling-rsync plugin run on Mac (and soon on Linux) and is far less
|
56
|
+
CPU-intensive than the built-in 'vagrant rsync-auto' plugin, at the cost of possibly
|
57
|
+
rsyncing more often.
|
58
|
+
email:
|
59
|
+
- steven.merrill@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- .ruby-version
|
66
|
+
- CHANGELOG.txt
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- example/files/.gitkeep
|
72
|
+
- example/vagrant/Vagrantfile
|
73
|
+
- lib/vagrant-gatling-rsync.rb
|
74
|
+
- lib/vagrant-gatling-rsync/command/rsync_auto.rb
|
75
|
+
- lib/vagrant-gatling-rsync/config.rb
|
76
|
+
- lib/vagrant-gatling-rsync/errors.rb
|
77
|
+
- lib/vagrant-gatling-rsync/listen/listenlinux.rb
|
78
|
+
- lib/vagrant-gatling-rsync/listen/listenosx.rb
|
79
|
+
- lib/vagrant-gatling-rsync/listen/listenwindows.rb
|
80
|
+
- lib/vagrant-gatling-rsync/plugin.rb
|
81
|
+
- lib/vagrant-gatling-rsync/version.rb
|
82
|
+
- locales/en.yml
|
83
|
+
- vagrant-gatling-rsync.gemspec
|
84
|
+
homepage: ''
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.0.14
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: A lighter-weight Vagrant plugin for watching and rsyncing directories.
|
108
|
+
test_files: []
|