我在本地使用 capistrano 预编译我的资产,并在使用 rsync 上传这些资产后,使用下一个代码deploy.rb:
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)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run_locally("rm -rf public/assets/*")
run_locally "bundle exec rake assets:precompile"
find_servers_for_task(current_task).each do |server|
#clean server assets before upload local new assets
run_locally "rsync -vr --exclude='.DS_Store' --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{server.host}:#{shared_path}/"
end
else
puts "Skipping asset pre-compilation because there were no asset changes"
end
end
end
问题是文件夹#{shared_path}/assets
在我每次部署时都在快速增长。
rm -rf public/assets/*
在在线上传本地新资产之前,我需要在生产服务器上运行代码#clean server assets before upload local new assets
我该怎么做?