设置rails请求超时(执行已过期)

wha*_*abi 7 timeout ruby-on-rails

应该是一个简单的,但谷歌没有帮助:无法找到一种方法让rails在请求到期之前等待更长时间

ActionView :: Template ::错误(执行已过期)

=> Booting Thin
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Run Code Online (Sandbox Code Playgroud)

Pat*_*non 5

First, gem list to see your rack_timeout version.

If you're using rack_timeout <= 0.4 then use

Rack::Timeout.timeout = 30 # seconds inside the config/initializers/timeout.rb
Run Code Online (Sandbox Code Playgroud)

If you're using rack_timeout >= 0.5 then use the following environment variables.

service_timeout:   15     # RACK_TIMEOUT_SERVICE_TIMEOUT
wait_timeout:      30     # RACK_TIMEOUT_WAIT_TIMEOUT
wait_overtime:     60     # RACK_TIMEOUT_WAIT_OVERTIME
service_past_wait: false  # RACK_TIMEOUT_SERVICE_PAST_WAIT
Run Code Online (Sandbox Code Playgroud)

In rails, you can load environment variables in a .env file:

gem 'dotenv-rails'
Run Code Online (Sandbox Code Playgroud)

In your config/environments/development.rb (or other) do:

Dotenv::Railtie.load
Run Code Online (Sandbox Code Playgroud)

Then, in the root of your rails project, your .env will look like:

RACK_TIMEOUT_SERVICE_TIMEOUT=15
RACK_TIMEOUT_WAIT_TIMEOUT=30
RACK_TIMEOUT_WAIT_OVERTIME=60
RACK_TIMEOUT_SERVICE_PAST_WAIT=false
Run Code Online (Sandbox Code Playgroud)


Tha*_* kp 4

如果您正在使用gem "rack-timeout" 然后更改文件Rack::Timeout.timeout = 30 # seconds内部或更多config/initializers/timeout.rb.使用此链接获取更多详细信息.