Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set rails request timeout (execution expired)

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
like image 752
whalabi Avatar asked Apr 06 '10 07:04

whalabi


2 Answers

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
like image 150
Patrice Gagnon Avatar answered Nov 04 '22 04:11

Patrice Gagnon


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.

like image 30
Thaha kp Avatar answered Nov 04 '22 05:11

Thaha kp