我最初在serverfault.com上发布了一个与此问题相关的问题:https://serverfault.com/questions/152587/apache-mod-proxy-to-another-server
我已经意识到这不是我的服务器设置问题,而是我的rails应用程序。我已经在服务器上设置了这个应用程序,就像我在同一台服务器上运行的另一个正常运行的rails应用程序一样。当我启动服务器时,我的mongrel.log看起来像这样:
** Daemonized, any open files are closed. Look at /var/www/osuwebdev/tmp/pids/mongrel.pid and log/mongrel.log for info.
** Starting Mongrel listening at 0.0.0.0:8080
** Starting Rails with production environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
** Rails signals registered. HUP => reload (without restart). It might not work well.
** Mongrel 1.1.5 available at 0.0.0.0:8080
** Writing PID file to /var/www/osuwebdev/tmp/pids/mongrel.pid
当我加载页面时,会弹出日志:
Wed Jun 30 19:46:10 +0000 2010: Error calling Dispatcher.dispatch #<NoMethodError: undefined method `[]' for nil:NilClass>
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:108:in `send_cookies'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:136:in `out'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_response.rb:65:in `start'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:135:in `out'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:81:in `process'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/bin/mongrel_rails:19:in `load'
/usr/local/bin/mongrel_rails:19
我无法弄清楚这款应用可能导致此问题的不同之处。
答案 0 :(得分:3)
我相信这是Rack,Mongrel和Rails中的一个奇怪的错误组合。
将此ruby代码保存在您的应用中config/mongrel.rb
:http://gist.github.com/471663
在config/environment.rb
中,在文件的最后添加:
require File.join(File.dirname(File.expand_path(FILE)), 'mongrel')
在同一个文件中,在Rails :: initializer.run块中添加以下行:
config.gem "mongrel"
此处问题的解释更长:https://rails.lighthouseapp.com/projects/8994/tickets/4690-mongrel-doesnt-work-with-rails-238
这对于Rails 2.3.8应用程序肯定有效,不过我修补它的方式与上述不同。
答案 1 :(得分:0)
您是否仍然在后续GET请求中看到问题?我有一个类似的问题,我的Rails应用程序在WEBrick下运行正常,但不在Mongrel下,但在互联网上找到了某个地方(here's a link显示了问题的类似版本)旧版本的Mongrel错误地处理了第一个请求页面,但处理后续请求确定。
我们提出的解决方法是,无论何时启动应用,我们都会curl
在应用上执行GET以“填充”Mongrel。
答案 2 :(得分:0)
这通常读取配置的yaml文件失败。它已设置一个配置对象来获取值,并且yaml文件中的条目不适用于您的环境,因此该对象为零。
您是否正在运行任何具有可能未设置用于开发的yaml文件的gem?
我不知道为什么回到2.3.5会有所帮助 - 它可能是以不同的顺序加载内容并且配置信息可用。