Extending the timeout for Rails processes through Passenger on Nginx

I recently had to allow for a long running reporting task in a Rails app which is running under Passenger (mod_rails) on Nginx

The default setting is 60 seconds and setting send_timeout to 300 in the Nginx config wasn’t working.
After much searching, I found the answer. Edit /ext/nginx/Conguration.c and change the lines:

ngx_conf_merge_msec_value(conf->upstream.send_timeout, prev->upstream.send_timeout, 60000);
ngx_conf_merge_msec_value(conf->upstream.read_timeout, prev->upstream.read_timeout, 60000);

to (for a 5 min timeout)

ngx_conf_merge_msec_value(conf->upstream.send_timeout, prev->upstream.send_timeout, 300000);
ngx_conf_merge_msec_value(conf->upstream.read_timeout, prev->upstream.read_timeout, 300000);

You will then need to recompile nginx and restart it (sending the HUP signal won’t work in this case)

Hope this helps someone else out there.

Comments (1)

BrianAugust 8th, 2009 at 04:55

Nice timing. Just ran into this today.