我认为这一切都始于我的主机(Bluehost)将其RoR升级到版本3的时间。
我第一次运行我的应用程序一小时后没有被访问它会引发错误(见下文)。如果我重新加载,则错误消失,数据库访问按预期工作。
我认为它可能是ActiveRecord的版本,但看起来好像Bluehost使用自己的版本(3.2.13)而不是我在配置(4.2.1)中安装的版本。
我怀疑它可能与Phusion Passenger和缓存连接有关,但我不确定如何诊断或修复它。
任何指针都非常感激。
根据命令行:
Ruby版本:1.9.3p429 Rails版本:3.2.13
Connecting to database specified by database.yml
Started GET "/" for xx.xx.xx.xxx at 2015-04-30 17:00:52 -0600
TypeError (can't convert nil into String):
mysql2 (0.3.11) lib/mysql2/client.rb:20:in `init_connection'
mysql2 (0.3.11) lib/mysql2/client.rb:20:in `initialize'
activerecord (3.2.13) lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
activerecord (3.2.13) lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/usr/lib64/ruby/1.9.3/monitor.rb:211:in `mon_synchronize'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/usr/lib64/ruby/1.9.3/monitor.rb:211:in `mon_synchronize'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
activerecord (3.2.13) lib/active_record/query_cache.rb:61:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__3881617127537431469__call__281038867919454016__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing'
/etc/httpd/modules/passenger/lib/phusion_passenger/rack/request_handler.rb:97:in `process_request'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_request_handler.rb:520:in `accept_and_process_next_request'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
/etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
/etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/utils.rb:470:in `safe_fork'
/etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb:180:in `start'
/etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
/etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
/etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/etc/httpd/modules/passenger/helper-scripts/passenger-spawn-server:99:in `<main>'
答案 0 :(得分:1)
看起来好像Bluehost使用自己的版本(3.2.13)而不是我在配置中安装的版本(4.2.1)
如果确实如此,当您在Gemfile
/ Gemfile.lock
中指定4.2.1时,您的托管服务提供商正在使用Rails 3.2.13,那么请获取新的托管服务提供商有两个原因。
首先,显然,您需要能够发布您知道在本地工作的应用程序版本。
其次,任何将3.2.13作为默认Rails版本的托管服务提供商应立即停业。在3.2.21之前的修补程序中修复了安全问题,除了最严重的安全问题之外,任何修复程序都不再支持整个3.2系列。
总结 - 我怀疑您的问题是由托管服务提供商的配置引起的。也许和他们交谈,看看你的app / server是否存在错误的配置,否则转移给其他人。