Skip to content

Commit

Permalink
Automatically add check_processing_services_online periodic task
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessavmac committed Jan 28, 2025
1 parent 37a0541 commit 1aba218
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.db import migrations
from django_celery_beat.models import PeriodicTask, CrontabSchedule


def create_periodic_task(apps, schema_editor):
crontab_schedule, _ = CrontabSchedule.objects.get_or_create(
minute="*/5", # Every 5 minutes
hour="*", # Every hour
day_of_week="*", # Every day
day_of_month="*", # Every day of month
month_of_year="*", # Every month
)

PeriodicTask.objects.get_or_create(
name="celery.check_processing_services_online",
task="ami.tasks.check_processing_services_online",
crontab=crontab_schedule,
)


def delete_periodic_task(apps, schema_editor):
# Delete the task if rolling back
PeriodicTask.objects.filter(name="celery.check_processing_services_online").delete()


class Migration(migrations.Migration):
dependencies = [
("main", "0044_merge_20250124_2333"),
]

operations = [
migrations.RunPython(create_periodic_task, delete_periodic_task),
]

0 comments on commit 1aba218

Please sign in to comment.