Django,uWSGI和nginx:进程死于“无故". [英] Django, uWSGI & nginx: Process dies for "no reason"

查看:584
本文介绍了Django,uWSGI和nginx:进程死于“无故".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用uWSGI和nginx运行两个并行的Django应用程序.其中之一,负载稍大(均为很小)的负载,每24小时就会死掉一次,并显示以下消息:

I am using uWSGI and nginx to run two parallell Django apps. One of them, the one with somewhat more load (both are very small) keeps dying about once every 24 hours with the following message:

[pid: 16358|app: 0|req: 1000/1000] 127.0.0.1 () {46 vars in 847 bytes} [Thu Mar 24 16:38:31 2011] GET /aktivitet/409/picknick/ => generated 18404 bytes in 117 msecs (HTTP/1.0 200) 3 headers in 156 bytes (1 switches on core 0) ...The work of process 16358 is done. Seeya!

[pid: 16358|app: 0|req: 1000/1000] 127.0.0.1 () {46 vars in 847 bytes} [Thu Mar 24 16:38:31 2011] GET /aktivitet/409/picknick/ => generated 18404 bytes in 117 msecs (HTTP/1.0 200) 3 headers in 156 bytes (1 switches on core 0) ...The work of process 16358 is done. Seeya!

我正在使用具有以下配置的Supervisor启动进程:

I am launching the processess using Supervisor with the following config:

[program:uttrakad] command=/home/myuser/webapps/uwsgi_test/bin/uwsgi -s /home/myuser/webapps/uwsgi_test/app1.sock -C /home/myuser/webapps/django/app1.wsgi --processes 1 --harakiri 120 --max-requests 1000 autostart=true autorestart=true stdout_logfile=/home/myuser/logs/user/uwsgi_app1.log redirect_stderr=true stopsignal=QUIT

[program:uttrakad] command=/home/myuser/webapps/uwsgi_test/bin/uwsgi -s /home/myuser/webapps/uwsgi_test/app1.sock -C /home/myuser/webapps/django/app1.wsgi --processes 1 --harakiri 120 --max-requests 1000 autostart=true autorestart=true stdout_logfile=/home/myuser/logs/user/uwsgi_app1.log redirect_stderr=true stopsignal=QUIT

.wsgi文件很简单:

The .wsgi file is simple:

import os import sys sys.path =['/home/openworks/webapps/django/lib/python2.6/','/home/openworks/webapps/django/','/home/openworks/webapps/django/app1/'] + sys.path from django.core.handlers.wsgi import WSGIHandler os.environ['DJANGO_SETTINGS_MODULE'] = 'app1.prod_settings' application = WSGIHandler()

import os import sys sys.path =['/home/openworks/webapps/django/lib/python2.6/','/home/openworks/webapps/django/','/home/openworks/webapps/django/app1/'] + sys.path from django.core.handlers.wsgi import WSGIHandler os.environ['DJANGO_SETTINGS_MODULE'] = 'app1.prod_settings' application = WSGIHandler()

nginx设置有2个工作进程,2048个worker_connections,如下所示: location / { uwsgi_pass unix:///home/openworks/webapps/uwsgi_test/app1.sock; include uwsgi_params; }

nginx is set up with 2 worker processes, 2048 worker_connections and like this: location / { uwsgi_pass unix:///home/openworks/webapps/uwsgi_test/app1.sock; include uwsgi_params; }

正如我所说,还有一个应用程序的配置与运行完全相同,没有中断,但是几乎没有流量.

As I said, there is one more app configured the exact same way that has been running without interuption, but is almost has no traffic.

有任何线索吗?为什么我得到" ...过程16358的工作已完成.Seeya"消息?

Any clues? Why do I get the "...The work of process 16358 is done. Seeya" messsage?

谢谢

推荐答案

查看日志:req:1000/1000

Look at the log: req: 1000/1000

您已将1000个最大请求数设置为

And you have set 1000 as the number of maxium requests.

即使在超级用户的监督下,也应始终在uwsgi上添加--master/-M,这将允许重新启动应用程序而不会丢失套接字(并且不会在重新启动过程中向客户端吐出错误).

You should always add --master/-M on uwsgi even under supervisord, this will allow to restart apps without losing the socket (and without spitting out an error to clients during restart).

这篇关于Django,uWSGI和nginx:进程死于“无故".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆