小编Mat*_*ngo的帖子

使用 gunicorn + nginx 长时间运行的请求

我已经为我们的 Django 驱动的应用程序组合了一个集成服务器。一些功能仍处于试验阶段,会导致请求过长。

我现在可以接受糟糕的表现,但我需要能够整合。每当我们使用导致长请求的功能时,应用程序就会挂起(如预期的那样),然后在大约一分半钟后返回“502 - Bad Gateway”。该应用程序的其余部分工作正常。

我检查了 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
Run Code Online (Sandbox Code Playgroud)

但是,这发生在实际工作人员超时之前很久,我将其设置为 10 分钟只是为了确保。这是运行 gunicorn 的 upstart 脚本的一部分。

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 …
Run Code Online (Sandbox Code Playgroud)

nginx django gunicorn

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

django ×1

gunicorn ×1

nginx ×1