我从ActiveResource收到一个非常奇怪的错误。我有一个方法调用另一个系统来获取产品列表。该列表非常大,生成和传输大约需要3分钟。因为这实际上只是一天一次,我建立了一个rake任务来运行它。在生产每当我运行rake任务时,它会因500错误而失败。这是一些示例输出
$ time RAILS_ENV=production rake api:sync
rake aborted!
Failed with 500 Internal Server Error
(See full trace by running task with --trace)
real 2m1.753s
user 0m1.188s
sys 0m0.188s
然后我尝试使用脚本运行器:
$ RAILS_ENV=production script/runner 'Product.synchronize!(ProductManager::Product.find_valid_products)'
/var/www/apps/api/releases/20091202203413/vendor/rails/railties/lib/commands/runner.rb:48: Failed with 500 Internal Server Error (ActiveResource::ServerError)
from /usr/local/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
from /usr/local/lib/ruby/1.8/timeout.rb:62:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:93:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from /usr/local/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /usr/local/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /usr/local/lib/ruby/1.8/net/http.rb:2020:in `read_status_line'
from /usr/local/lib/ruby/1.8/net/http.rb:2009:in `read_new'
... 17 levels...
from /var/www/apps/api/releases/20091202203413/vendor/rails/railties/lib/commands/runner.rb:48
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/runner:3
但是,如果我跳进控制台运行它,一切都很好:
$ script/console production
Loading production environment (Rails 2.3.5)
>> Product.synchronize!(ProductManager::Product.find_valid_products); nil # prevent dump to console
=> nil
>>
我怀疑是超时,所以我在ProductManager :: Product类上将超时值设置为5分钟,但这没有效果。有趣的是,当我通过rake或script / runner运行时,错误发生在2分1秒,并且没有失败。在开发和分期中没有问题。 ActiveResource的生产是否有某种我无法找到的隐藏的2分钟覆盖?
如果您没有从跟踪中获取它,我们将Rails 2.3.5冻结到应用程序中。谢谢你的帮助
对等
答案 0 :(得分:0)
原来这是一个Apache设置。 httpd.conf文件中的RequestTimeout为120秒。一旦我们认为一切都很好。