1

カピストラーノを介してデプロイを実行すると、アセットが本番環境でコンパイルされるように、カピストラーノを構成しました。MongoDbデータベースでRuby 1.9.3、Rails 3.2.13を使用しています。問題は展開中にのみ存在し、開発と本番の両方で問題なくアセットを手動でコンパイルできます

desc "Update the deployed code."
task :update_code, :except => { :no_release => true } do
  run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
  finalize_update
  assets.precompile
end

namespace :assets do
  desc "Assets precompileing"
  task :precompile, :roles => :web, :except => { :no_release => true } do
    run "cd #{current_path}; rm -rf public/assets/*"
    run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} assets:precompile"
  end
end

しかし、私はこのエラーが発生しています

executing command
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby /my-app/path/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
undefined method `[]' for nil:NilClass
/my-app/path/shared/bundle/ruby/1.9.1/gems/moped-1.4.5/lib/moped/protocol/reply.rb:71:in `command_failure?'
/my-app/path/shared/bundle/ruby/1.9.1/gems/moped-1.4.5/lib/moped/node.rb:82:in `block in command'
/my-app/path/shared/bundle/ruby/1.9.1/gems/moped-1.4.5/lib/moped/node.rb:582:in `[]'
/my-app/path/shared/bundle/ruby/1.9.1/gems/moped-1.4.5/lib/moped/node.rb:582:in `block (3 levels) in flush'
/my-app/path/shared/bundle/ruby/1.9.1/gems/moped-1.4.5/lib/moped/node.rb:581:in `map'
...
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
    command finished in 14427ms
failed: "env RAILS_ENV=production sh -c 'cd /my-app/path/current; bundle exec rake RAILS_ENV=production assets:precompile'"
zlib(finalizer): the stream was freed prematurely.

したがって、アセット内の特別なファイルとは関係ありません。純粋な .js および .css ファイルのみを使用します。

私が使用している複数のマニフェスト ファイルに問題があるのではないかと考えましたが、config.assets.precompile += ['another-manifest.js', 'another-manifest.css'] を追加しました。

デプロイ中にアセットのコンパイルをオフにし、デプロイが終了した後に手動で行うと、開発と本番で魅力的に機能します。

また、self のみを必要とするマニフェスト ファイルを 1 つだけ残してみましたが、エラーはまだ存在していました。

Mongoid のドキュメントでは、ヒント セクション http://mongoid.org/en/mongoid/docs/tips.htmlで説明されている同様の問題が発生しました。

しかし、現在 1.9.3 Ruby ビルド p392 を使用しているので、問題ないはずです。

これに関するどんな助けも素晴らしいでしょう!

4

1 に答える 1