vagrant-syncer

Less CPU hog Vagrant rsync(-auto) for large file hierarchies (macOS, GNU/Linux, Windows)

MIT License

Downloads
42K
Stars
10
Committers
1

vagrant syncer

Note: This project is unmaintained, feel free to fork/PR.

This Vagrant plugin optimizes to the following Vagrant commands to not be that CPU hog with large file hierachies:

vagrant rsync
vagrant rsync-auto

All the rsync synced folder settings are supported. They also have the same default values for backwards compatibility.

Installation

vagrant plugin install vagrant-syncer

Updating

vagrant plugin update vagrant-syncer

Configuration

See the example Vagrantfile for additional plugin specific config.syncer settings and their default values.

Changes to the Vagrant's rsync and rsync-auto

  • The plugin has leaner rsync implementation with most of the rsync command
    argument constructing already handled in the class initializer and not
    sync-time (in the sync loop).
  • Uses rb-fsevent and
    rb-inotify gems underneath for
    performance on OS X and GNU/Linux respectively, instead of using Listen.
    On Windows, Listen is used though as using plain wdm gem requires some tests.
  • Allow defining additional SSH arguments to rsync in Vagrantfile using
    config.syncer.ssh_args. Use this for e.g. disabling SSH compression to
    lower CPU overhead.
  • Runs vagrant rsync-auto to start watching changes after vagrant up,
    reload and resume, if config.syncer.run_on_startup set to true
    in Vagrantfile.
  • Vagrant's implementation assumes that the primary group of the SSH user
    has the same name as the user, if rsync option group is not explicitly
    defined. This plugin queries the user's real primary group from the guest.
  • Hooking Vagrant's :rsync_pre is removed, as this unnecessarily runs
    mkdir to create the target directory, which rsync command creates sync-time
    anyway.
  • On Windows, expect relative paths, instead of Cygwin style, as Cygwin shall
    not be a requirement.
  • ControlPath settings are not in the default SSH arguments on Windows,
    as they fail on
    Vagrant 1.8.0 and 1.8.1.
  • Hide "permanently added to the known hosts" messages from rsync stderr output.
  • The rsync stdout outputs are all single line by default, and colored.

Development

Fork this repository, clone it and install Ruby 2.2.3, using e.g. rbenv:

cd vagrant-syncer
rbenv install $(cat .ruby-version)
gem install bundler -v1.12.5
bundle install

Then use it with:

bundle exec vagrant rsync-auto

Or outside the bundle:

./build_and_install.sh
vagrant rsync-auto

Also, I kindly take pull requests.

Credits

vagrant-syncer was originally put together by Anssi Syrjäsalo.

Thanks to Steven Merrill's (@stevenmerrill) vagrant-gatling-rsync for the listener implementations and the original idea to tap into rb-fsevent (OS X) and rb-inotify (GNU/Linux) for non-CPU hog watching of hierarchies with 10,000-100,000 files.

And to Hashicorp for Vagrant, even though its future will likely be overshadowed by Otto.