From 891c6d272f1fa65a48ca3375d5a032d79db8ce06 Mon Sep 17 00:00:00 2001 From: Haresh Kainth Date: Tue, 10 Dec 2024 20:09:50 +0000 Subject: [PATCH] chore: updated delay startup for celery-worker and minor improvements --- celery_worker/tasks.py | 10 ++++++++++ docker-compose.yml | 2 +- fbr/settings.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/celery_worker/tasks.py b/celery_worker/tasks.py index 28d22c9..80f8b6c 100644 --- a/celery_worker/tasks.py +++ b/celery_worker/tasks.py @@ -1,5 +1,15 @@ +# flake8: noqa + +import os import time +import django + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fbr.settings") + +# Initialize Django setup +django.setup() + from celery import shared_task from app.cache.legislation import Legislation diff --git a/docker-compose.yml b/docker-compose.yml index 5f5c15d..533cbcf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,7 +89,7 @@ services: interval: 10s timeout: 5s retries: 2 - start_period: 5s + start_period: 15s depends_on: - redis - db diff --git a/fbr/settings.py b/fbr/settings.py index 3014743..8ebc4c6 100644 --- a/fbr/settings.py +++ b/fbr/settings.py @@ -154,7 +154,7 @@ CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers.DatabaseScheduler" CELERY_RESULT_EXTENDED = True CELERY_TASK_TIME_LIMIT = ( - 450 # Maximum runtime for a task in seconds (e.g., 7.5 minutes) + 900 # Maximum runtime for a task in seconds (e.g., 900/60 = 15 minutes) ) CELERY_TASK_SOFT_TIME_LIMIT = ( 270 # Optional: Grace period before forced termination