Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to limit synching to specified directories #80

Merged
merged 6 commits into from
Jun 16, 2014

Conversation

jimmynotjim
Copy link
Contributor

See #63

  • Adds rsync_limited var
  • Adds :limited task to both :up and :down

NOTE: Rather than change the functionality of the current :files task I thought it better to add an :limited task to synch the directories specified (with /uploads as the default). This is really useful when converting really old sites with lots of cruft over to Genesis.

To test on a Genesis project run

bower install git@github.com:genesis/wordpress.git#63-rsync-uploads-dir

and select the branch when prompted.

Adds 'local_uploads' and 'remote_uploads' vars and ':uploads' task to both ':up' and ':down'
@ericclemmons
Copy link
Contributor

Man, you're right on. I usually don't care about anything but those. I do think that perhaps we should pivot off of shared.

@jimmynotjim
Copy link
Contributor Author

I tried making this work as a one line rsync like this:

        desc "Downloads shared children files to Vagrant"
        task :shared, :roles => :web do
            set :excludes, "--exclude '#{rsync_exclude.join('\' --exclude \'')}'"
            set :remote_children, "\'#{remote_web}/#{shared_children.join(' '"#{remote_web}"'/')}\'"

            ssh = "-e \"ssh -i #{ssh_options[:keys][0]}\"" unless ssh_options.keys.empty?

            find_servers_for_task(current_task).each do |current_server|
                system "chmod 600 #{ssh_options[:keys][0]}" unless ssh_options.keys.empty?
                system "rsync #{ssh} -avvru --delete --copy-links #{excludes} --progress #{'--dry-run' if dry_run} #{user}@#{current_server}:#{remote_children} #{local_web}/wp-content/"
            end
        end

but the only issue is rsync removes the parent directories of the source, so without appending /wp-content on the destination the bottom source directory (in this case /uploads) are copied directly to /web.

The other option would be to loop through each key in shared_children like this:

        desc "Downloads shared children files to Vagrant"
        task :shared, :roles => :web do
            set :excludes, "--exclude '#{rsync_exclude.join('\' --exclude \'')}'"

            ssh = "-e \"ssh -i #{ssh_options[:keys][0]}\"" unless ssh_options.keys.empty?

            find_servers_for_task(current_task).each do |current_server|
                system "chmod 600 #{ssh_options[:keys][0]}" unless ssh_options.keys.empty?
                shared_children.each do |key|
                    system "rsync #{ssh} -avvru --delete --copy-links #{excludes} --progress #{'--dry-run' if dry_run} #{user}@#{current_server}:#{remote_web}/#{key}/ #{local_web}/#{key}/"
                end
            end
        end

What do you think?

@jimmynotjim
Copy link
Contributor Author

Went ahead w/ the second option. I've tested it on a few projects and it seems to be working just fine.

@jimmynotjim
Copy link
Contributor Author

Bah! Just realized this doesn't work with staging/production as the :remote_web path and /uploads path in :shared_children both contain the /web directory. How is :shared_children processed by Cap? Can we assume they're in the /web dir or should we go with a new variable for this task?

@jimmynotjim
Copy link
Contributor Author

Temporarily closing so this isn't merged by accident.

Avoids any issues w/ dir overlap in remote/local_web vars and shared_children vars
@ericclemmons
Copy link
Contributor

You can leave it open, and just put [RFC] or [WIP] in the title for clarity...

@jimmynotjim jimmynotjim reopened this Dec 12, 2013
@jimmynotjim
Copy link
Contributor Author

Cool. I changed to a dedicated "rsync_limited" var to avoid the issue w/ duplicate dirs in "shared_children" and "remote/local_web". Thoughts?

* master: (43 commits)
  Install tasksel
  Add auto_correct to Vagrantfile
  Default WordPress to latest, then 3.7.1
  Bump to v0.2.41
  Bump to v0.2.40
  Simplified wp cookie regex (based on cookie regex we're using in production.vcl)
  Removed some version changes that shouldn't have been there (part of the revert)
  Switch from 0.2.* to ~0.2.36 versioning
  Forcing minimum MaxClients value of 5
  Fixed underscore cookie match in varnish vcl
  Revert rollback of v0.2.38
  Bump to v0.2.39
  Bump to v0.2.38
  Bump to v0.2.37
  Bump to v0.2.36
  Add more detail to v0.2.35
  Bump to v0.2.35
  Move events from after deploy:update
  Bump to v0.2.34
  Added Vagrant troubleshooting in README
  ...
@jimmynotjim
Copy link
Contributor Author

I've thoroughly tested this on both existing Genesis setups and site conversions and it's been running like a champ. Let me know if you figure out some way to test these types of tasks and I'll make an attempt at writing some.

* master: (21 commits)
  Remove genesis version
  Remove debug code
  Fix hosts addon
  console.log(browser.html());
  sudo mkdir
  Symlink web to /vagrant/web
  Debug mode
  Correct bower install
  bower install in test/temp
  Install latest genesis-wordpress branch
  Install tasksel
  Install before generation
  NPM install
  Install bower
  sudo provision me a sandwhich
  Working functional test
  Add travis-ci badge
  Add .travis.yml
  Initial mocha test
  Force sourceRoot
  ...
@AntJanus
Copy link
Contributor

@ericclemmons @jimmynotjim should we merge this down and start using it? It looks like it's been lurking here for months.

@jimmynotjim
Copy link
Contributor Author

I've just been waiting for someone to give the 👍 I've tested it on multiple projects and it works great.

@ericclemmons
Copy link
Contributor

I think we can merge this down safely for now. For v0.3.0, I think this should be the default behavior and introduce that BC break.

@jimmynotjim
Copy link
Contributor Author

ben-stiller-is-retro-do-it-reaction-gif

@jimmynotjim
Copy link
Contributor Author

Sooo....this going to get merged down?

@jimmynotjim
Copy link
Contributor Author

Monthly reminder...

@ericclemmons ericclemmons added this to the v0.2.51 milestone Jun 12, 2014
ericclemmons added a commit that referenced this pull request Jun 16, 2014
Added support to limit synching to specified directories
@ericclemmons ericclemmons merged commit 0295674 into master Jun 16, 2014
@jimmynotjim
Copy link
Contributor Author

Whoohooo. Now to update projects to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants