我已经为我们的Django驱动的应用程序整合了一个集成服务器。 一些function仍然是实验性的,并导致过长的请求。
我现在的performance还不错,但我需要能够整合。 无论何时我们使用导致长时间请求的function,应用程序都会挂起(如预期的那样),然后在一分半钟后返回“502 – 错误的网关”。 应用程序的其余部分工作正常。
我检查了gunicorn日志,每当发生这种情况,我得到一条线
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
然而,这发生在实际的工人超时之前,我已经设置为10分钟,以确保。 这是运行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
我正在运行gunicorn版本0.13.4。 任何帮助将不胜感激。
502 Bad Gateway意味着你的gunicorn工人超时。 你可以添加 – --timeout选项到gnuicorn命令。 默认值是30秒。
正如@ greg-k所指出的,Nginx的proxy_read_timeout选项控制着另一个超时。 如果您看到504 Gateway Timeout错误,您可以调整此选项。
这可能是你的nginxconfiguration的一个问题。 你configuration了proxy_read_timeout值吗?
该指令设置代理服务器响应的读取超时。 它决定了nginx将等待获取对请求的响应的时间。 超时不是build立在整个响应上,而是只在两次读取之间进行。
来源: http : //wiki.nginx.org/HttpProxyModule#proxy_read_timeout