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

发布于 2024-08-27 19:05:47 字数 309 浏览 4 评论 0原文

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

ActionView::Template::Error(执行已过期)

=> 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

Should be an easy one but google isn't helping: can't find a way to get rails to wait longer before a request expires

ActionView::Template::Error (execution expired)

=> 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

说不完的你爱 2024-09-03 19:05:48

首先,gem list 查看您的rack_timeout 版本。

如果您使用 rack_timeout <= 0.4,则使用

Rack::Timeout.timeout = 30 # seconds inside the config/initializers/timeout.rb

如果您使用 rack_timeout >= 0.5,则使用以下环境变量。

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

在rails中,您可以在.env文件中加载环境变量:

gem 'dotenv-rails'

在config/environments/development.rb(或其他)中执行:

Dotenv::Railtie.load

然后,在rails项目的根目录中,您的.env将如下所示:

RACK_TIMEOUT_SERVICE_TIMEOUT=15
RACK_TIMEOUT_WAIT_TIMEOUT=30
RACK_TIMEOUT_WAIT_OVERTIME=60
RACK_TIMEOUT_SERVICE_PAST_WAIT=false

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

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

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

gem 'dotenv-rails'

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

Dotenv::Railtie.load

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
嗳卜坏 2024-09-03 19:05:48

如果您使用gem“rack-timeout”
然后在 config/initializers/timeout.rb 文件中更改 Rack::Timeout.timeout = 30 # 秒或更多。
使用此链接了解更多详细信息。

If you are using gem "rack-timeout"
Then change the Rack::Timeout.timeout = 30 # seconds or more inside the config/initializers/timeout.rb file.
Use this link for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文