mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 15:56:56 +00:00
24 lines
718 B
Python
24 lines
718 B
Python
import os
|
|
|
|
from django.apps import AppConfig
|
|
|
|
|
|
class LettersConfig(AppConfig):
|
|
name = "letters"
|
|
|
|
def ready(self):
|
|
"""
|
|
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"
|
|
or os.environ.get("UVICORN_MAIN") == "true"
|
|
):
|
|
return
|
|
from .tasks import start_scheduler
|
|
|
|
start_scheduler()
|