[Refs #263] Speed up deploy if assets didn't change

This commit is contained in:
Vladimir Sharshov 2012-03-27 02:19:47 +04:00
parent 5c574a74e4
commit 3d2fedb594
1 changed files with 14 additions and 2 deletions

View File

@ -7,14 +7,13 @@ set :default_environment, {
'LANG' => 'en_US.UTF-8'
}
# set :rake, "rake --trace"
#set :rake, "#{rake} --trace"
require 'rvm/capistrano'
require 'bundler/capistrano'
require 'delayed/recipes'
require 'airbrake/capistrano'
set :whenever_command, "bundle exec whenever"
# require "whenever/capistrano"
@ -67,6 +66,19 @@ namespace :deploy do
task :symlink_pids, :roles => :app do
run "cd #{fetch :shared_path}/tmp && ln -nfs ../pids pids"
end
# Speed up precompile (http://www.bencurtis.com/2011/12/skipping-asset-compilation-with-capistrano )
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} app/assets/ lib/assets/ vendor/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
end
after "deploy:finalize_update", "deploy:symlink_all"