From 640ae4bba030a120be08d89378ea613239b2f088 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:44:38 +0530 Subject: [PATCH] chore: clear workspace license on restart (#939) --- apiserver/bin/docker-entrypoint-api-ee.sh | 3 +++ .../commands/clear_workspace_licenses.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 apiserver/plane/ee/management/commands/clear_workspace_licenses.py diff --git a/apiserver/bin/docker-entrypoint-api-ee.sh b/apiserver/bin/docker-entrypoint-api-ee.sh index f3448ffc73..28e0cc4123 100755 --- a/apiserver/bin/docker-entrypoint-api-ee.sh +++ b/apiserver/bin/docker-entrypoint-api-ee.sh @@ -33,4 +33,7 @@ python manage.py create_bucket # Clear Cache before starting to remove stale values python manage.py clear_cache +# Clear workspace licenses +python manage.py clear_workspace_licenses + exec gunicorn -w "$GUNICORN_WORKERS" -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:"${PORT:-8000}" --max-requests 1200 --max-requests-jitter 1000 --access-logfile - diff --git a/apiserver/plane/ee/management/commands/clear_workspace_licenses.py b/apiserver/plane/ee/management/commands/clear_workspace_licenses.py new file mode 100644 index 0000000000..77727bf98f --- /dev/null +++ b/apiserver/plane/ee/management/commands/clear_workspace_licenses.py @@ -0,0 +1,17 @@ +# Django imports +from django.core.management import BaseCommand + +# Module imports +from plane.ee.models import WorkspaceLicense + + +class Command(BaseCommand): + help = "Clear the workspace licenses on the start up" + + def handle(self, *args, **options): + # Clear the workspace licenses + WorkspaceLicense.objects.all().delete() + self.stdout.write( + self.style.SUCCESS("Workspace licenses cleared successfully") + ) + return