Skip to content

Commit

Permalink
update: make celery run task every day by midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
Tha-Orakkle committed Mar 3, 2025
1 parent d8f4f0f commit 2940aa4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/utils/celery_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
celery_app.conf.beat_schedule = {
"clean_db_every_day": {
"task": "api.utils.celery_config.clean_expired_and_revoked_tokens_from_sessions_table",
"schedule": crontab(day_of_week=0, hour=0, minute=0)# run every sunday midnight
"schedule": crontab(hour=0, minute=0) # run everyday at midnight
}
}

celery_app.conf.timezone = "UTC"

# Additional configurations
celery_app.conf.update(
task_serializer='json',
result_serializer='json',
accept_content=['json'],
task_acks_late=True,
worker_prefetch_multiplier=1,
task_time_limit=300,
task_soft_time_limit=180,
)

@celery_app.task
def clean_expired_and_revoked_tokens_from_sessions_table():
"""Clean expired and revoked tokens from the sessions table."""
Expand Down

0 comments on commit 2940aa4

Please sign in to comment.