fix sentry logging in conjunction with celery

This commit is contained in:
Jannis Gebauer 2015-09-30 10:39:25 +02:00
parent 25326d5560
commit b465ccc9b2

View File

@ -4,6 +4,10 @@ import os
from celery import Celery
from django.apps import AppConfig
from django.conf import settings
{% if cookiecutter.use_sentry == "y" -%}
from raven import Client
from raven.contrib.celery import register_signal
{%- endif %}
if not settings.configured:
# set the default Django settings module for the 'celery' program.
@ -23,6 +27,13 @@ class CeleryConfig(AppConfig):
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
{% if cookiecutter.use_sentry == "y" -%}
if hasattr(settings, 'RAVEN_CONFIG'):
# Celery signal registration
client = Client(dsn=settings.RAVEN_CONFIG['dsn'])
register_signal(client)
{%- endif %}
@app.task(bind=True)
def debug_task(self):