13

アプリケーションをデプロイしようとしていますが、

*** [err :: xxx.xxx.xx.xxx] bash: line 1:  9953 Killed                  bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile

問題は、プロセスに時間がかかりすぎることだと思います。ログにエラーはなく、top異常も見られませんでした。私がなんとかログから抜け出すことができたのは、それが殺しているプロセスがapplication.jsコンパイルであるように見えるということです。

ローカルで実行したときrake assets:precompile、エラー/警告はありませんでした。

capistranoがプロセスを強制終了する前に待機する長さを延長できますか?それは実際に問題ですか?他にどこを見ればいいですか?

アップデート

走っているとき

bundle exec rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets --trace

次の出力が得られます

** Invoke assets:precompile (first_time)
** Execute assets:precompile
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
Killed

私が走るとき

bundle exec rake assets:precompile RAILS_ENV=production --trace

私は得る

**アセットの実行:プリコンパイル

.../.rvm/rubies/ruby-1.9.3-p374/bin/ruby path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace

** Invoke assets:precompile:all (first_time)

** Execute assets:precompile:all

** Invoke assets:precompile:primary (first_time)

** Invoke assets:environment (first_time)

** Execute assets:environment

** Invoke tmp:cache:clear (first_time)

** Execute tmp:cache:clear

** Execute assets:precompile:primary

rake aborted!

Command failed with status (): [/home/user/.rvm/rubies/ruby-1.9.3-p374...]

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:12:in `ruby_rake_task'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'

/home/user/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'

path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake:23:in `load'

path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake:23:in `<main>'

Tasks: TOP => assets:precompile

これは、ステージングディレクトリでは発生しません。顔を見つめているような気がします

4

1 に答える 1

17

したがって、私たちの問題は、ブートストラップ-sassがアセットの事前コンパイルの一部であったことだと思います。つまり、すべてのcssを爆破し、それをすべてコンパイルしていました。これを大量のsass/cssと組み合わせると、プロセスは大量のメモリを使用し、OSはそれを強制終了します。多くの調査の後、私はかなりまともな解決策に出くわしました。ローカルでコンパイルし、圧縮し、アップロードし、サーバーで解凍し、サーバーでシンボリックリンクしてから、作成されたすべての余分なファイル(ローカルアセット/圧縮ファイル)を削除します。

これがスクリプトです

namespace :deploy do
  namespace :assets do

    task :precompile, :roles => :web do
      from = source.next_revision(current_revision)
      if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
        run_locally("RAILS_ENV=#{rails_env} rake assets:clean && RAILS_ENV=#{rails_env} rake assets:precompile")
        run_locally "cd public && tar -jcf assets.tar.bz2 assets"
        top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp
        run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2"
        run_locally "rm public/assets.tar.bz2"
        run_locally("rake assets:clean")
      else
        logger.info "Skipping asset precompilation because there were no asset changes"
      end
    end

    task :symlink, roles: :web do
      run ("rm -rf #{latest_release}/public/assets &&
            mkdir -p #{latest_release}/public &&
            mkdir -p #{shared_path}/assets &&
            ln -s #{shared_path}/assets #{latest_release}/public/assets")
    end
  end

  # other stuff...

end

ここでスクリプトを見つけました。それはより良い説明を提供します

編集

新しいレールの展開に問題がありました。正確なバージョンはわかりませんが、Rails 4に影響を与えているようです。アセットは、コンパイル対象の環境を指定する必要があります。そうしないと、本番/ステージング環境でそれらが見つかりません。

于 2013-03-09T22:47:48.047 に答える