Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
eaf3ad1f
Commit
eaf3ad1f
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Plain Diff
Merge branch '312-send-emails-for-celery-tasks-with-status-failure' into 'master'
Resolve "Send emails for celery tasks with status "FAILURE"" Closes
#312
See merge request
!877
parents
70b78f85
1ccd7a7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!877
Resolve "Send emails for celery tasks with status "FAILURE""
Pipeline
#49381
canceled
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
aleksis/core/celery.py
+27
-0
27 additions, 0 deletions
aleksis/core/celery.py
aleksis/core/templates/templated_email/celery_failure.email
+44
-0
44 additions, 0 deletions
aleksis/core/templates/templated_email/celery_failure.email
with
72 additions
and
0 deletions
CHANGELOG.rst
+
1
−
0
View file @
eaf3ad1f
...
...
@@ -13,6 +13,7 @@ Added
~~~~~
* Add preference for configuring the default phone number country code.
* Admins recieve an mail for celery tasks with status "FAILURE"
Added
~~~~~
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/celery.py
+
27
−
0
View file @
eaf3ad1f
import
os
from
django.conf
import
settings
from
celery
import
Celery
from
celery.signals
import
task_failure
from
templated_email
import
send_templated_mail
from
.util.core_helpers
import
get_site_preferences
os
.
environ
.
setdefault
(
"
DJANGO_SETTINGS_MODULE
"
,
"
aleksis.core.settings
"
)
app
=
Celery
(
"
aleksis
"
)
# noqa
app
.
config_from_object
(
"
django.conf:settings
"
,
namespace
=
"
CELERY
"
)
app
.
autodiscover_tasks
()
@task_failure.connect
def
task_failure_notifier
(
sender
=
None
,
task_id
=
None
,
exception
=
None
,
args
=
None
,
traceback
=
None
,
**
kwargs
):
recipient_list
=
[
e
[
1
]
for
e
in
settings
.
ADMINS
]
send_templated_mail
(
template_name
=
"
celery_failure
"
,
from_email
=
get_site_preferences
()[
"
mail__address
"
],
recipient_list
=
recipient_list
,
context
=
{
"
task_name
"
:
sender
.
name
,
"
task
"
:
str
(
sender
),
"
task_id
"
:
str
(
task_id
),
"
exception
"
:
str
(
exception
),
"
args
"
:
str
(
args
),
"
kwargs
"
:
str
(
kwargs
),
"
traceback
"
:
str
(
traceback
),
},
)
This diff is collapsed.
Click to expand it.
aleksis/core/templates/templated_email/celery_failure.email
0 → 100644
+
44
−
0
View file @
eaf3ad1f
{% load i18n %}
{% block subject %}
{% blocktrans with task_name=task_name%} Celery task {{ task_name }} failed!{% endblocktrans %}
{% endblock %}
{% block plain %}
{% trans "Hello," %}
{% blocktrans with task_name=task_name %}
the celery task {{ task_name }} failed with following information:
{% endblocktrans %}
{% blocktrans with task_name=task_name task=task task_id=task_id exception=exception args=args kwargs=kwargs traceback=traceback %}
* Task name: {{task_name}}
* Task: {{task}}
* Id of the task: {{task_id}}
* Exception instance raised: {{ exception }}
* Positional arguments the task was called with: {{ args }}
* Keyword arguments the task was called with: {{ kwargs }}
* Stack trace object: {{ traceback }}
{% endblocktrans %}
{% endblock %}
{% block html %}
<p>{% trans "Hello," %}</p>
<p>
{% blocktrans with task_name=task_name %}
the celery task {{ task_name }} failed with following information:
{% endblocktrans %}
</p>
<ul>
{% blocktrans with task_name=task_name task=task task_id=task_id exception=exception args=args kwargs=kwargs traceback=traceback %}
<li>Task name: {{task_name}}</li>
<li>Task: {{task}}</li>
<li>Id of the task: {{task_id}}</li>
<li>Exception instance raised: {{ exception }}</li>
<li>Positional arguments the task was called with: {{ args }}</li>
<li>Keyword arguments the task was called with: {{ kwargs }}</li>
<li>Stack trace object: {{ traceback }}</li>
</ul>
{% endblocktrans %}
{% endblock %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment