MT#56231 enable django-celery-beat via database

* migrate periodic task definition to database
  via configuration

Be aware that we are getting hit by this issue:
https://github.com/celery/django-celery-beat/issues/647
Solution is not yet released:
2798e36fd8

Change-Id: Id72130bdd5fe97be3824f5d9d7a3905af44d3597
mprokop/trixie
Victor Seva 3 years ago committed by Víctor Seva
parent 8db117160b
commit 50c0287543

@ -15,7 +15,6 @@
import os
from celery import Celery
from celery.schedules import crontab
from django_structlog.celery.steps import DjangoStructLogInitStep
# set the default Django settings module for the 'celery' program.
@ -49,12 +48,3 @@ def process_result(jbi_id: str, path_envVars: str):
"release_changed.tasks.process_result",
args=[jbi_id, path_envVars],
)
@app.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):
sender.add_periodic_task(
crontab(hour=7, minute=30, day_of_month=15),
"gerrit.tasks.cleanup",
args=[4],
)

@ -32,6 +32,7 @@ INSTALLED_APPS = [
"rest_framework_api_key",
"drf_spectacular",
"django_assets",
"django_celery_beat",
"django_celery_results",
"django_extensions",
"django_filters",
@ -169,5 +170,6 @@ CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
CELERY_ACCEPT_CONTENT = ["application/json"]
CELERY_RESULT_BACKEND = "django-db"
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
API_KEY_CUSTOM_HEADER = "HTTP_API_KEY"

@ -161,6 +161,11 @@ CELERY_BEAT_SCHEDULE = {
"schedule": crontab(hour=7, minute=30, day_of_week="sunday"),
"args": (None, 1),
},
"gerrit-cleanup": {
"schedule": crontab(hour=7, minute=30, day_of_month=15),
"tasks": "gerrit.tasks.cleanup",
"args": (4),
},
}
CELERY_TIMEZONE = "UTC"

Loading…
Cancel
Save