mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-03 13:14:28 +03:00
fix sentry logging in conjunction with celery
This commit is contained in:
parent
25326d5560
commit
b465ccc9b2
|
@ -4,6 +4,10 @@ import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
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:
|
if not settings.configured:
|
||||||
# set the default Django settings module for the 'celery' program.
|
# 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.config_from_object('django.conf:settings')
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
|
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)
|
@app.task(bind=True)
|
||||||
def debug_task(self):
|
def debug_task(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user