我正在我的Django应用程序通过uwsgi服务器和我开始32个进程在我的init脚本-args是:UWSGI
ARGS="--pidfile ${PIDFILE} --uid ${UID} -s /tmp/${NAME}.sock --pythonpath ${GCS_HOME}/server/src/gcs --master -w wsgi -d ${GCS_HOME}/logs/uwsgi.log -p 32 -z 30"
版本的Python 2.6.5,Django的1.2.1,uWSGI 0.9.5.1
我想拥有一个日志文件,因此我使用了基于多处理的日志处理程序,如question 641420中所述。
multilogging处理程序在我有一个简单的测试应用程序中工作正常,当我运行带有werkzeug的manage.py runserver_plus时,但是当我使用django和uwsgi运行时没有记录任何内容(我没有从uwsgi虽然过程)。
我WSGI文件如下,如果任何人都可以认同我的配置有问题或正在发生的事情我会很感激的解释:
APP_VIRTUAL_ENV = "/home/devadmin/gcs/server/gcs_env/"
APP_PARENT_PATH = "/home/devadmin/gcs/server/src/"
##
import sys
# Redirect stdout to comply with WSGI
sys.stdout = sys.stderr
import os, site
# Set the settings module django should use
os.environ['DJANGO_SETTINGS_MODULE'] = "gcs.settings"
# set the sys.path
site_packages_subpath = "/lib/python%s.%s/site-packages" % (sys.version_info[0]\
, sys.version_info[1],)
site_packages_path = os.path.join(APP_VIRTUAL_ENV, site_packages_subpath[1:])
sys_path = []
for path in sys.path:
if site_packages_subpath in path and not path.startswith(APP_VIRTUAL_ENV):
continue
sys_path.append(path)
sys.path = [ APP_PARENT_PATH ]
sys.path += sys_path
site.addsitedir(site_packages_path)
# reorder sys.path
for path in sys_path:
sys.path.remove(path)
sys.path += sys_path
# setup logging
import os.path
import logging
import logging.config
logging.config.fileConfig(os.path.join(os.path.dirname(__file__), "logging.conf\
"))
很难说,你的配置文件是什么样子的?你运行的是什么版本的Python?您正在导入但不使用`multiproc_handler`,并且由于某种原因,您没有使用在实际的`fileConfig`调用中计算出的`log_conf_file`。 – 2010-11-26 11:40:43
添加上面的版本并从wsgi.py中删除虚假行(它们是我在做某些调试时留下的。还指出,当我使用werkzeug/runserver_plus时,日志记录是可以的。所以它会表明我的日志记录不能通过wsgi.py正确初始化。当我使用标准的Python日志处理程序(RotatingLogFileHandler)时,我得到日志输出,但这不是多个uwsgi进程的解决方案。 – rtmie 2010-11-26 13:42:51