uWSGI&Django 1.4 – 错误的网关,没有错误

我很难让Django和uWSGI在Ubuntu(12)上玩得很好。 似乎wsgi正在加载,然后该应用程序立即崩溃。 没有一个uwsgi日志给我任何东西去。 我正在使用标准的Django 1.4 wsgi与下面的uwsgiconfiguration:

[uwsgi] project = djangoproject base_dir = /home/www/mywebsite.com uid = www-data gid = www-data plugins = http,python processes = 4 harakiri = 60 reload-mercy = 8 cpu-affinity = 1 max-requests = 2000 limit-as = 512 reload-on-as = 256 reload-on-rss = 192 no-orphans = True vacuum = True master = True logto = /var/log/uwsgi/%n.log catch-exceptions virtualenv = %(base_dir)/venv chdir = %(base_dir) module = %(project).wsgi socket = /run/uwsgi/%n.sock chmod-socket = 666 

这是我的日志文件说:

 [uWSGI] getting INI configuration from mywebsite.ini *** Starting uWSGI 1.0.3-debian (32bit) on [Sun Oct 7 23:52:26 2012] *** compiled with version: 4.6.2 on 20 February 2012 10:06:16 current working directory: /etc/uwsgi/apps-enabled detected binary path: /usr/bin/uwsgi-core limiting address space of processes... your process address space limit is 536870912 bytes (512 MB) your memory page size is 4096 bytes *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers *** uwsgi socket 0 inherited UNIX address /run/uwsgi/mywebsite.sock fd 3 Python version: 2.7.3 (default, Aug 1 2012, 05:27:35) [GCC 4.6.3] Set PythonHome to /home/www/mywebsite.com/venv Python main interpreter initialized at 0x9944570 your server socket listen backlog is limited to 100 connections *** Operational MODE: preforking *** PRINT STATEMENT FROM WSGI.PY WSGI application 0 (mountpoint='') ready on interpreter 0x9944570 pid: 6130 (default app) *** uWSGI is running in multiple interpreter mode *** gracefully (RE)spawned uWSGI master process (pid: 6130) spawned uWSGI worker 1 (pid: 6146, cores: 1) set cpu affinity for worker 1 to 0 spawned uWSGI worker 2 (pid: 6147, cores: 1) set cpu affinity for worker 2 to 1 spawned uWSGI worker 3 (pid: 6148, cores: 1) set cpu affinity for worker 3 to 2 spawned uWSGI worker 4 (pid: 6149, cores: 1) set cpu affinity for worker 4 to 3 

我看不到任何内容,这就解释了为什么应用程序崩溃了。 我还向wsgi.py添加了打印语句,以确保正确加载。

作为参考,这里是我的wsgi:

 import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoproject.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() 

我不认为uWSGI(或Django)崩溃。 uWSGI在死亡/重新加载时非常冗长,而你的头衔报告了一个“坏门户”错误,这是另一回事。 检查你的networking服务器日志也许这是一些configuration错误