2013-01-04 95 views
1

我有/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。

+0

您目前如何部署這些資產?你是否預編譯它們並將它們添加到存儲庫?你預先編譯它們並且rsync它們嗎?當你說你的'現有資產'只有3.2 MB時,你指的是你的開發'public/assets'文件夾還是你的'app/assets'文件夾? – theIV

+0

Yeahh。我更新了我的問題。我是在實時服務器生產預編譯的資產,但現在我已經更改爲本地計算機上的預編譯和rsync上傳後。我指的是我的公衆/資產的重量是3.2 MB。非常感謝你! – hyperrjas

+0

你有沒有嘗試在你的rsync任務中添加'--delete'?從rsync手冊頁:' - 刪除dest目錄下的無關文件。 – theIV

回答

0

在您的rsync命令中嘗試使用--delete

從rsync手冊頁:--delete delete extraneous files from dest dirs.

+0

如何才能知道涉及舊版本舊版本的資產?有可能保留默認數量的資產,例如部署版本。 – hyperrjas