Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,10 @@
offset=timedelta(seconds=KEYCLOAK_ORG_SYNC_OFFSET),
),
},
"clear-expired-tokens": {
"task": "main.tasks.clear_expired_tokens",
"schedule": crontab(minute=0, hour=9, day_of_week=1), # every week
},
}

# Hijack
Expand Down
15 changes: 15 additions & 0 deletions main/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging

from celery import shared_task
from django.core.management import call_command

log = logging.getLogger(__name__)


@shared_task
def run_cleartokens():
try:
call_command("cleartokens")
log.info("Successfully ran cleartokens management command.")
except Exception:
log.exception("Error running cleartokens")