Question

My thin server is timing out after 30 seconds. I would like to override this ruby file.

DEFAULT_TIMEOUT from 30 seconds to 120 seconds. how to do it? Please let me know.

code is here: https://github.com/macournoyer/thin/blob/master/lib/thin/server.rb

I would like to override without "already initialized constant" Warnings.

Was it helpful?

Solution

See the help

➜  ~/app ✓ thin --help | grep timeout
   -t, --timeout SEC                Request or command timeout in sec (default: 30)

So you can change it from the command line when starting the server

➜  ~/app ✓ thin --timeout 60 start

or you can set a config file somewhere like /etc/thin/your_app.yml with something like this

---
timeout: 60

and then run thin, pointing it at this YAML file with

thin -C /etc/thin/your_app.yml start

As a side note, you should consider if increasing your timeout is really necessary. Typically long running requests should be queued up and run later through a service like delayed_job or resque


After seeing your comment and learning you're using Heroku, I suggest you read the documentation

Occasionally a web request may hang or take an excessive amount of time to process by your application. When this happens the router will terminate the request if it takes longer than 30 seconds to complete. The timeout countdown begins when the request leaves the router. The request must then be processed in the dyno by your application, and then a response delivered back to the router within 30 seconds to avoid the timeout.

I even more strongly suggest looking into delayed_job, resque, or similar if you're using Heroku. You will have at least one worker running to handle the queue. HireFire is an excellent service to save you money by only spinning up workers when your queue actually has jobs to process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top