2009-12-03 86 views
1

我从ActiveResource得到一个非常奇怪的错误。我有一种方法调用另一个系统来获取产品列表。该清单非常大,需要大约3分钟才能生成和传输。由于这真的只有一天一次有点事,我建立了一个rake任务来运行它。在生产中,每当我运行rake任务时,都会失败,并显示500错误。下面是一些示例输出ActiveResource 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或脚本/ runner运行时,错误发生在2分钟和1秒内,没有失败。在开发和分期中没有问题。生产的ActiveResource有某种隐藏的2分钟覆盖我找不到?

如果你没有从轨迹中得到它,我们使用Rails 2.3.5冻结到应用程序中。感谢您的帮助

对等

+0

AFAIK活动资源中没有2分钟的任何内容。虽然也许HTTP客户端有它自己的超时。 – 2010-12-10 18:33:09

+0

OOC - 当您在控制台中运行它时。多久时间?即它需要> 2分钟,还是真的运行得很快(因为你已经同步)? – 2010-12-10 18:35:28

回答

0

原来,这是一个Apache的设置。 httpd.conf文件中的RequestTimeout为120秒。一旦我们宣布一切都很好。