feat: enable scheduler execution in Docker by checking UVICORN_MAIN environment variable

This commit is contained in:
ramvignesh-b
2026-04-29 02:20:18 +05:30
parent 4893c91c20
commit 150832419a
2 changed files with 8 additions and 3 deletions
+6 -2
View File
@@ -10,9 +10,13 @@ class LettersConfig(AppConfig):
"""
Start the scheduler only when the server is starting.
NOTE: If we don't check for RUN_MAIN, the scheduler triggers for all django operations (migration, test etc.)
NOTE++: For uvicorn, we make sure to set the env var `UVICORN_MAIN` to `true` in the docker command.
"""
if not (os.environ.get("RUN_MAIN") == "true" or os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
if not (
os.environ.get("RUN_MAIN") == "true"
or os.environ.get("WERKZEUG_RUN_MAIN") == "true"
or os.environ.get("UVICORN_MAIN") == "true"
):
return
from .tasks import start_scheduler