我有/home/name/apps/myapp/shared/assets"
乾淨共享/資產對生產服務器導軌夾3
我看到,因爲這目錄正在迅速增長的生產服務器上我的資產。現在的體重文件夾是40 Mb,但我目前的資產有3.2 MB的重量
我的問題是我怎麼能用capistrano自定義任務清理這個舊資產文件夾。我只需要最後的資產,當我做出最後cap deploy
編輯:
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)} 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|
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.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
我預編譯資產生產服務器上,但我已經改變了預編譯的資產本地機器與rsync。
您目前如何部署這些資產?你是否預編譯它們並將它們添加到存儲庫?你預先編譯它們並且rsync它們嗎?當你說你的'現有資產'只有3.2 MB時,你指的是你的開發'public/assets'文件夾還是你的'app/assets'文件夾? – theIV
Yeahh。我更新了我的問題。我是在實時服務器生產預編譯的資產,但現在我已經更改爲本地計算機上的預編譯和rsync上傳後。我指的是我的公衆/資產的重量是3.2 MB。非常感謝你! – hyperrjas
你有沒有嘗試在你的rsync任務中添加'--delete'?從rsync手冊頁:' - 刪除dest目錄下的無關文件。 – theIV