Rails,Nginx和PostgreSQL - 502网关错误

时间:2011-09-26 10:59:34

标签: ruby-on-rails postgresql nginx passenger

我在Linode上运行Ubuntu 11.04,我正试图让Rails 3.1,Nginx 1.0.6,Passenger 3.0.9和PostgreSQL 8.4设置并运行。我已经设法部署了我的应用程序,它似乎完美地工作但是在几次成功的HTTP请求之后服务器开始返回502网关错误。

我查看了Nginx日志,它似乎是一个PostgreSQL问题,我在我的OS X开发机器上使用相同的设置(PostgreSQL 8.4,Rails 3.1和WEBrick),它运行得很好。

有谁知道问题可能是什么?


2011/09/26 11:43:41 [error] 19694#0: *152 upstream prematurely closed connection while reading response header from upstream, client: <REDACTED>, server: localhost, request: "GET /news/new HTTP/1.0", upstream: "passenger:unix:/passenger_helper_server:", host: "<REDACTED>"
[ pid=19978 thr=-609427238 file=utils.rb:176 time=2011-09-26 11:43:41.504 ]: *** Exception PGError in application (server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.**
) (process 19978, thread #<Thread:0xb759c1b4>):
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `query'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:276:in `clear_cache!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `each_value'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:275:in `clear_cache!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:303:in `disconnect!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `disconnect_without_synchronization!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `each'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:201:in `disconnect_without_synchronization!'
        from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:35:in `disconnect!'
        from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/core_ext/module/synchronization.rb:34:in `disconnect!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `each_value'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:395:in `clear_all_connections!'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `__send__'
        from /var/lib/gems/1.8/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `clear_all_connections!'
        from /opt/passenger-3.0.9/lib/phusion_passenger/utils.rb:398:in `before_handling_requests'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:204:in `start_request_handler'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:170:in `send'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:170:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/utils.rb:479:in `safe_fork'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:180:in `start'
        from /opt/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
        from /opt/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
        from /opt/passenger-3.0.9/helper-scripts/passenger-spawn-server:99

----------

谢谢!

1 个答案:

答案 0 :(得分:1)

在这种情况下写入日志PostgreSQL的内容是什么?必须有一些理由来关闭连接 - 也许是旧版本的PostgreSQL?