【发布时间】:2013-01-09 11:27:08
【问题描述】:
我想知道我将把它放在我的代码或 gunicorn 的什么地方,以便让 raven 运行。 http://raven.readthedocs.org/en/latest/config/django.html#gunicorn
【问题讨论】:
标签: python gunicorn sentry raven
我想知道我将把它放在我的代码或 gunicorn 的什么地方,以便让 raven 运行。 http://raven.readthedocs.org/en/latest/config/django.html#gunicorn
【问题讨论】:
标签: python gunicorn sentry raven
有点晚了,但无论如何:)
您需要将此添加到您的 Gunicorn 配置文件中。例如,当您启动 gunicorn_django 时,您可以传递一个 -c (--config) 参数,该参数采用 python 文件的路径。
Gunicorn 将使用此文件加载未作为参数传递的配置设置,如工作程序和日志路径等。但您也可以包含 gunicorn 将在进程生命周期的某些点调用的函数。根据 Raven 文档,这是放置 raven 设置的地方。
例如:
$ gunicorn_django -c /path/to/gunicorn_settings.py
该文件可能包含以下内容:
workers = 2
bind = 'unix:/tmp/my_project_name.sock' # Binds to a unix socket rather than ip/port
errorlog = '/path/to/logs/gunicorn.error.log'
def when_ready(server):
from django.core.management import call_command
call_command('validate')
注意确保您的DJANGO_SETTINGS_MODULE 正确导出,否则call_command('validate') 将抛出SystemExit 并且您的进程将无法启动。
您可以阅读更多关于 Gunicorn 配置文件的信息:http://docs.gunicorn.org/en/latest/configure.html
【讨论】: