Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've put together an integration server for our Django-powered application. A few of the features are still experimental, and result in overly long requests.

I'm okay with the poor performance, for now, but I need to be able to integrate. Whenever we use the feature that leads to a long request, the app hangs (as expected) and then, after maybe a minute and a half, returns a '502 - Bad Gateway'. The rest of the app works fine.

I checked the gunicorn log, and whenever this happens I get a line like

2012-01-20 17:30:13 [23128] [DEBUG] GET /results/
2012-01-20 17:30:43 [23125] [ERROR] WORKER TIMEOUT (pid:23128)
Traceback (most recent call last):
  File "/home/demo/python_envs/frontend/lib/python2.6/site-packages/gunicorn/app/base.py", line 111, in run
    os.setpgrp()
OSError: [Errno 1] Operation not permitted

however, this happens long before the actual worker timeout, which I've set to 10 minutes just to make sure. Here's part of the upstart script that runs gunicorn.

description "..."

start on runlevel [2345]
stop on runlevel [!2345]
#Send KILL after 5 seconds
kill timeout 5
respawn

env VENV="/path/to/a/virtual/env/"

#how to know the pid
pid file $VENV/run/guniconr-8080.pid

script
exec sudo -u demo $VENV/bin/gunicorn_django --preload --daemon -w 4 -t 600 --log-level debug --log-file $VENV/run/gunicorn-8080.log -p $VENV/run/gunicorn-8080.pid -b localhost:8080 /path/to/settings.py
end script

I'm running gunicorn version 0.13.4. Any help would be greatly appreciated.

share|improve this question
add comment

2 Answers

502 Bad Gateway means your gunicorn worker is timeout. You can add --timeout option to the gnuicorn command. The default is 30s.

As @greg-k notes, proxy_read_timeout option of Nginx controls yet another timeout. If you see 504 Gateway Timeout error, you can adjust this option.

share|improve this answer
    
It's been a while since I've worried about this, but- isn't that the same at the -t option I already had in the question? –  Matt Luongo Jan 2 '13 at 3:33
add comment

This is maybe an issue with your nginx configuration. Did you configure the proxy_read_timeout value?

This directive sets the read timeout for the response of the proxied server. It determines how long nginx will wait to get the response to a request. The timeout is established not for entire response, but only between two operations of reading.

Source: http://wiki.nginx.org/HttpProxyModule#proxy_read_timeout

share|improve this answer
    
I just moved to a larger/faster server for development ($$ :(), but if this comes up again I'll test your suggestion! –  Matt Luongo Jun 6 '12 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.