[英]Django+Satchmo using nginx+FastCGI after some time gives HTTP Error 502 Bad gateway
I installed new Satchmo store on Linux Debian 6 distributive. 我在Linux Debian 6发行版上安装了新的Satchmo商店。 Standard Django development server works perfect, but in production mode with nginx + FastCGI after some time (or it's look like after some memory limit will be overfilled) nginx output "502 Bad gateway" error.
标准Django开发服务器可以完美运行,但是在生产模式下使用nginx + FastCGI需要一段时间(或者看起来在超出某些内存限制之后),nginx输出“ 502 Bad gateway”错误。
In log files I found these lines: 在日志文件中,我找到了以下几行:
2011/12/02 02:38:57 [error] 29894#0: *91439 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 2.95.158.164, server: my-secret-host.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/www/file.sock:", host: "my-secret-host.com"
2011/12/02 02:38:57 [错误] 29894#0:* 91439 recv()失败(104:对等方重置连接),同时从上游读取响应标头,客户端:2.95.158.164,服务器:my-secret- host.com,请求:“ GET / HTTP / 1.1”,上游:“ fastcgi:// unix:/var/run/www/file.sock:”,主机:“ my-secret-host.com”
I was searching over internet a lot and found nginx can't get right response from my django fastcgi server. 我在互联网上进行了大量搜索,发现Nginx无法从django fastcgi服务器得到正确的响应。 I tried different settings of django server (maxchildren, maxrequests), but the error still here (conclusion is higher values - longer life without error).
我尝试了django服务器的不同设置(maxchildren,maxrequests),但错误仍然存在(结论是更高的值-寿命更长,没有错误)。 With settings maxchildren=3 maxrequests=10 error randomly appears after 5-10 page refreshes and after 15 refreshes it appears always.
在设置maxchildren = 3 maxrequests = 10的情况下,刷新5-10页后将随机出现错误,刷新15次后将始终显示错误。
I also found when I comment some lines of satchmo source code error is gone. 当我评论satchmo源代码错误的某些行时,我也发现了。 That's is very strange, because it's very important lines for right working store.
这很奇怪,因为对于正确的商店来说,这是非常重要的路线。 I think it can be a clue to the reason of problem.
我认为这可能是问题原因的线索。 Diff is here: http://dpaste.com/hold/664978/
差异在这里: http : //dpaste.com/hold/664978/
Problem disappear if I would: 如果我愿意,问题消失了:
PAYMENT_PROCESSOR=True
line in my only payment module. PAYMENT_PROCESSOR=True
行注释掉。 config_register(MultipleStringValue(SHIPPING_GROUP, ...)
in shipping/config.py
shipping/config.py
注释掉config_register(MultipleStringValue(SHIPPING_GROUP, ...)
I think these lines lead to real reasons of crashing my production server. 我认为这些行直接导致了生产服务器崩溃的真正原因。 How I can solve this problem completely?
我如何才能完全解决这个问题? Any suggestions to my investigation?
对我的调查有什么建议吗?
UPDATE: 更新:
After enabling satchmo logging I found this message: 启用satchmo日志记录后,我发现以下消息:
Mon, 05 Dec 2011 13:26:37 configuration ERROR Problem finding settings SHOP.SHOW_SITE, server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
2011年12月5日星期一13:26:37配置错误查找设置SHOP.SHOW_SITE时出现问题,服务器意外关闭了连接。这很可能意味着服务器在处理请求之前或期间异常终止。
Probably it's possible to solve this using recipe from here https://groups.google.com/group/satchmo-users/browse_thread/thread/506b3ad77e7a766e?hl=es&pli=1 . 可能可以使用https://groups.google.com/group/satchmo-users/browse_thread/thread/506b3ad77e7a766e?hl=es&pli=1上的食谱来解决此问题。 I will try this a little bit later.
我稍后会尝试。
This is caused by a problem with the database connection . 这是由数据库连接问题引起的。
Rationale: The first part of the error message "configuration ERROR Problem finding settings SHOP.SHOW_SITE" is from livesettings. 原理:错误消息的第一部分“配置错误,问题查找设置SHOP.SHOW_SITE”来自实时设置。 It is usually the first module that uses the database.
通常,它是使用数据库的第一个模块。 The second part after comma "server closed the connection unexpectedly..." is a message from Postgres database client about connection to db server.
逗号“服务器意外关闭连接...”之后的第二部分是Postgres数据库客户端发出的有关与数据库服务器连接的消息。
Database connection, number of active connections and db settings can be tested by following commands: 数据库连接,活动连接数和数据库设置可以通过以下命令进行测试:
$ python manage.py dbshell
postgres=> select * from product_product; -- something typical
postgres=> select * from pg_stat_activity; -- active connections
postgres=> show all; -- show current db server settings
You should take a look at your Satchmo log files and see if there are more details about the reason for this crash. 您应该查看您的Satchmo日志文件,并查看是否有更多有关此崩溃原因的详细信息。 The items you commented out shouldn't prevent a crash, so I suspect there is something else going on with your deployment setup.
您注释掉的项目不应防止崩溃,因此我怀疑您的部署设置还有其他问题。
Another item to consider, are you using a threaded vs. non-threaded Fast-cgi? 要考虑的另一项内容,您是使用线程还是非线程Fast-cgi?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.