提供未压缩的资产时,Rails 3.1:间歇性500内部服务器错误 [英] Rails 3.1: Intermittent 500 Internal Server Error when serving uncompressed assets

查看:64
本文介绍了提供未压缩的资产时,Rails 3.1:间歇性500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序升级到Rails 3.1.经常引用,Firebug会抱怨一些资产.这是从Firebug粘贴的一些错误:

I'm upgrading an app to Rails 3.1. Quote often, Firebug will complain about some assets. Here are some errors pasted from Firebug:

"NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/jquery-ui.js?body=1"
jquery...?body=1
"NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/pages/file_attachments.js"
file_a...ents.js
"NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/file_attachments/sortable.js?body=1"
sortab...?body=1
"NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/jquery.js?body=1"

刷新页面将产生显示相同错误的不同资产.当我复制并粘贴URL时,我看到的文件就很好了.

Refreshing the page would yield different assets showing the same error. When I copy and paste the URL I see the files just fine.

我正在使用:

  • Ubuntu 11.04
  • Apache + Passenger 3.0.9

我该如何解决?

更新:日志文件

在此特定实例中,jquery-ui.js显示Firebug中的错误.我的日志文件如下所示:

In this particular instance, jquery-ui.js was showing an error in Firebug. My log file looked like this:

Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011
Served asset /jquery.js - 304 Not Modified (0ms)


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011


Started GET "/admin/site/sites/storage.js" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011
Served asset /jquery_ujs.js - 304 Not Modified (0ms)


Started GET "/assets/application.js?body=1" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011
  Processing by Admin::Site::SitesController#storage as JS
Served asset /application.js - 304 Not Modified (3ms)
  ...
Rendered admin/site/sites/storage.js.erb (0.1ms)
Completed 200 OK in 58ms (Views: 5.1ms | ActiveRecord: 21.1ms)


Started GET "/assets/admin/logo.png" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011
Served asset /admin/logo.png - 304 Not Modified (0ms)

似乎已跳过jquery-ui.js

更新,2011年10月1日:

UPDATE Oct 1, 2011:

我对独立乘客(passenger start)进行了尝试,因为它似乎给出了更具描述性的错误.当我尝试仅加载jquery.js文件并反复按CTRL-R刷新浏览器并重复加载该资产时,会发生这种情况.

I tried it out with the standalone passenger (passenger start) as it seems to give a more descriptive error. This is what happens when I try to load just the jquery.js file and press CTRL-R repeatedly to refresh my browser and load that asset repeatedly.

Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2011-10-01 21:40:18 +0800
[ pid=29485 thr=3066030960 file=ext/nginx/HelperAgent.cpp:931 time=2011-10-01 21:40:18.691 ]: Uncaught exception in PassengerServer client thread:
   exception: Cannot read response from backend process: Connection reset by peer (104)
   backtrace:
     in 'void Client::forwardResponse(Passenger::SessionPtr&, Passenger::FileDescriptor&, const Passenger::AnalyticsLogPtr&)' (HelperAgent.cpp:603)
     in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:857)
     in 'void Client::threadMain()' (HelperAgent.cpp:950)

2011/10/01 21:40:18 [error] 29522#0: *16 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /assets/jquery.js?body=1 HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "get.unstilted.dev:3000"
[ pid=29674 thr=78131090 file=utils.rb:176 time=2011-10-01 21:40:18.699 ]: *** Exception PGError in application (server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
) (process 29674, thread #<Thread:0x9505f24>):
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `exec'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `block in clear_cache!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `each_value'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `clear_cache!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:303:in `disconnect!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in disconnect!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `each'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `disconnect!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:35:in `block in disconnect_with_synchronization!'
        from /home/ramon/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect_with_synchronization!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `block in clear_all_connections!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `each_value'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!'
        from /home/ramon/.rvm/gems/ruby-1.9.2-p290@unstilted/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `clear_all_connections!'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/utils.rb:398:in `before_handling_requests'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/utils.rb:479:in `safe_fork'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server.rb:180:in `start'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
        from <internal:prelude>:10:in `synchronize'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /home/ramon/.passenger/standalone/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002/support/helper-scripts/passenger-spawn-server:99:in `<main>'
Served asset /jquery.js - 304 Not Modified (0ms)
cache: [GET /assets/jquery.js?body=1] stale, valid, store
[ pid=29485 thr=3064224624 file=ext/nginx/HelperAgent.cpp:921 time=2011-10-01 21:40:18.734 ]: Couldn't forward the HTTP response back to the HTTP client: It seems the user clicked on the 'Stop' button in his browser.

推荐答案

问题出在Passenger and Rails 3.1 PostgreSQL适配器的中间. 根据此问题, https://github.com/rails/rails/issues/1339 Rails 3.1.1.rc1应该已解决此问题.

The problem is in the middle of Passenger and Rails 3.1 PostgreSQL adapter. According to this issue https://github.com/rails/rails/issues/1339 Rails 3.1.1.rc1 should have this issue fixed.

也请停止使用PassengerSpawnMethod conservative,因为它使乘客&最终REE性能优化没有用-它产生了单独的Rails实例-不会共享通用代码.

Also stop using PassengerSpawnMethod conservative because it makes Passenger & eventually REE performance optimizations useless - it spawns separate Rails instances - no sharing of common code.

这篇关于提供未压缩的资产时,Rails 3.1:间歇性500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆