我正在使用一个使用MySQL空间扩展的Rails(2.3.4)应用程序,因此我正在使用GeoRuby(1.3.4)和spatial_adapter(1.1.2)宝石。
自从我开始使用GeoRuby的Point对象以来,当ActiveSupport在处理请求后尝试删除常量时,我遇到了麻烦:
[ pid=18105 thr=67398490 file=utils.rb:176 time=2010-12-07 15:00:38.894 ]: *** Exception NameError in application (cannot remove Object::Geometry) (process 18105, thread #<Thread:0x808d6b4>):
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_const'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_constant'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `instance_eval'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:603:in `remove_constant'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `remove_unloadable_constants!'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:450:in `remove_unloadable_constants!'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:236:in `clear'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:64:in `cleanup_application'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:17:in `close'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/rack/request_handler.rb:136:in `process_request'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/utils.rb:479:in `safe_fork'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /opt/local/lib/ruby/gems/1.8/gems/passenger-3.0.0/helper-scripts/passenger-spawn-server:99
最终这会导致Apache收到SIGTERM(可能是因为它耗尽线程或其他东西),所以服务器偶尔无法响应任何请求。
有一件事奇怪的是'Object :: Geometry' - 我希望能够读取'GeoRuby :: SimpleFeatures :: Geometry'(我正在使用几个GeoRuby :: SimpleFeatures :: Point's,这是一个几何的子类)。
我还注意到,在ActiveSupport 3.0.0中,remove_constant的代码与我正在使用的版本有所不同。此更新是否解决了此问题,如果是,那是否需要更新Rails 3.0?
答案 0 :(得分:0)
我通过在active_support / dependencies.rb中使用begin-rescue-end子句包围有问题的代码(remove_constant方法体)来修复它,以忽略该异常。我不确定这是否有任何负面的副作用,但至少它不会导致Apache不时重启。