2012-02-27 15 views
6

私はこのカピストラーノタスクがあります。Rails 3.2.1は、デプロイ時にプリコンパイルされたアセットですか?

namespace :deploy do 
    task :precompile, :role => :app do 
    run "cd #{release_path}/ && RAILS_ENV=staging bundle exec rake assets:precompile --trace" 
    end 
end 

after "deploy:finalize_update", "deploy:precompile" 

を私はload 'deploy/assets'があることを知っているが、私はここで何が起こっているのかを理解しようとしています。私は明らかに常に50%のCPUを持っているアマゾンEC2 m1.smallインスタンスに展開しています

topで検証時間を盗みます。 これは、資産をコンパイルするための時間の増加につながるが、これを見て:

[23.21.xxx.xx] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /home/ubuntu/apps/myapp-rails/releases/20120227020245/ && RAILS_ENV=staging bundle exec rake assets:precompile --trace' 
** [out :: 23.21.xxx.xx] ** Invoke assets:precompile (first_time) 
** [out :: 23.21.xxx.xx] ** Execute assets:precompile 
** [out :: 23.21.xxx.xx] /home/ubuntu/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /home/ubuntu/apps/myapp-rails/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets --trace 
** [out :: 23.21.xxx.xx] ** Invoke assets:precompile:all (first_time) 
** [out :: 23.21.xxx.xx] ** Execute assets:precompile:all 
** [out :: 23.21.xxx.xx] ** Invoke assets:precompile:primary (first_time) 
** [out :: 23.21.xxx.xx] ** Invoke assets:environment (first_time) 
** [out :: 23.21.xxx.xx] ** Execute assets:environment 
** [out :: 23.21.xxx.xx] ** Invoke environment (first_time) 
** [out :: 23.21.xxx.xx] ** Execute environment 
** [out :: 23.21.xxx.xx] ** Invoke tmp:cache:clear (first_time) 
** [out :: 23.21.xxx.xx] ** Execute tmp:cache:clear 
** [out :: 23.21.xxx.xx] ** Execute assets:precompile:primary 
** [out :: 23.21.xxx.xx] ** Invoke assets:precompile:nondigest (first_time) 
** [out :: 23.21.xxx.xx] ** Invoke assets:environment (first_time) 
** [out :: 23.21.xxx.xx] ** Execute assets:environment 
** [out :: 23.21.xxx.xx] ** Invoke environment (first_time) 
** [out :: 23.21.xxx.xx] ** Execute environment 
** [out :: 23.21.xxx.xx] ** Invoke tmp:cache:clear (first_time) 
** [out :: 23.21.xxx.xx] ** Execute tmp:cache:clear 
** [out :: 23.21.xxx.xx] ** Execute assets:precompile:nondigest 
    command finished in 958131ms 

私はそれが二度、それらをコンパイルだと言うことができますいくつかの理由のために資産をプリコンパイルに費やされた時間の非常識量APART。どうして?

私はRails 3.2.1を使用しています。 誰かがここで何が起こっているかについていくつかの洞察を提供することはできますか?それは意図されていますか?

staging.rb 

    # Compress JavaScripts and CSS 
    config.assets.compress = true 

    # Don't fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = false 

    # Generate digests for assets URLs 
    config.assets.digest = true 

答えて

10

load 'deploy/assets'自動的にデプロイの適切な部分にあなたのための資産をプリコンパイルしますので、プリコンパイルタスクを定義する必要はありません。プリコンパイル・タスクとafter "deploy:finalize_update", "deploy:precompile"の両方を削除できます。

https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy/assets.rb

編集:あなたがtrueに設定さダイジェスト持っているときに、デフォルトのレールには、フィンガープリントされたファイルと非フィンガープリントされたファイルが作成されます。実際には、プリコンパイル・タスク全体を2回実行するのではなく、状況ごとに1つのタスクを実行するだけです。

指紋以外のファイルの生成を完全に無効にする場合は、assets:precompile:allタスクを上書きできます。

Rake::Task['assets:precompile:all'].clear 
namespace :assets do 
    namespace :precompile do 
    task :all do 
     Rake::Task['assets:precompile:primary'].invoke 
     # ruby_rake_task("assets:precompile:nondigest", false) if Rails.application.config.assets.digest 
    end 
    end 
end 

コメントアウト行は、ここではライン66である:私はこのカピストラーノタスクについて知っていることを私の質問で述べた

https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake

+0

。私はそれをオフにした1)私はそれとスプライトに問題がある2)私は何が起こっているかを明確にチェックしたいと思った。 – kain

+0

私はいくつかの詳細と私の答えを更新しました。ありがとうございます; – James

+2

;それぞれの状況に対して1つのタスクを実行することは私にとっては愚かなように思えます。なぜ地球上のレールでオプションをチェックすることができず、それに応じて1つのタスクしか実行できないのですか...ダイジェスト、誰かがダイジェストではなくダイエットしたいと思ったら、分けてください。 – kain

関連する問題