basecamp / fast_remote_cache Goto Github PK
View Code? Open in Web Editor NEWA faster version of Capistrano's remote_cache deployment strategy
License: MIT License
A faster version of Capistrano's remote_cache deployment strategy
License: MIT License
Although the copy.rb script will make the copy into the release directory fast, this time is actually just shifting to the git reset --hard
command since it will break all the hard links, even for unchanged files. Breaking hard links equates to copying the file to replace the hard link.
Ideally this would be fixed in git, but as a workaround I found that git reset --mixed #{revision} && git checkout -f .
checks out the files without breaking hard links, so actually speeds up deploys when using fast_remote_cache.
Adding the following to config/deploy.rb will speed up deploys by using avoid git reset --hard
.
module FastGitSync
def sync(revision, destination)
git = command
remote = origin
branch = head
execute = []
execute << "cd #{destination}"
execute << "#{git} fetch #{verbose} #{remote} +#{branch}:refs/remotes/#{remote}/#{branch}"
# Reset the git index
execute << "#{git} reset #{verbose} --mixed #{revision}"
# Checkout the index into the work tree
execute << "#{git} checkout -f ."
# Remove untracked files
execute << "#{git} clean #{verbose} -d -x -f"
execute.join(" && ")
end
end
set(:source) { Capistrano::Deploy::SCM.new(scm, self).extend(FastGitSync) }
Some conditions from sync where removed for brevity. See the original source for the sync method for details.
Any thoughts on how this change should be integrated into fast_remote_cache?
Trying to use fast_remote_cache for the first time, I get:
copying the cached version to /data/myapp/releases/20100317102524
* executing "ruby /data/myapp/shared/bin/copy.rb /data/myapp/shared/cached-copy /data/myapp/releases/20100317102524 test doc && (echo 211ffbb4792233899a947d745fb89e14d0d0374b > /data/myapp/releases/20100317102524/REVISION)"
servers: ["myhost.com"]
[myhost.com] executing command
** [out :: myhost.com] ruby:
** [out :: myhost.com] No such file or directory -- /data/myapp/shared/bin/copy.rb (LoadError)
command finished
I'm on ruby 1.8.7, Capistrano 2.5.18, Rails 2.3.5 with the proper line in my Capfile. I added:
set :deploy_via, :fast_remote_cache
set :copy_exclude, %w(test doc)
to my config/deploy.rb
Here is the full deploy log: https://gist.github.com/1931a5a675becab7a13d
Why is it running "git ls-remote"? Isn't that superseded by fast_remote_cache?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.