smo*_*ter 5 ruby-on-rails heroku
我正在使用heroku在支持iOS应用程序的rails应用程序上托管ruby.我的请求可能会运行很长时间,我需要能够在请求被杀之前捕获超时.我正在使用Timeout :: timeout(15)抛出错误并正确处理它.这在我的本地工作正常,我可以看到错误被抛出和记录.当我在heroku上运行相同的代码时,不会记录任何错误.尝试使用机架超时gem时我遇到了同样的问题.
是否有其他人在Heroku上运行时遇到问题?我在雪松上.
# app/controllers/index_controller.rb
require 'timeout'
Class IndexController < ApplicationController
def timeout
begin
status = Timeout::timeout(5) {
sleep(6)
render :text => "will never be rendered"
rescue Timeout::Error
render :text => "timeout handled"
end
end
end
end
# config/routes.rb
match '/timeout' => "index#timeout"
Run Code Online (Sandbox Code Playgroud)
这在heroku上运行良好:http ://young-gorge-7585.herokuapp.com
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |