You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
864 B
23 lines
864 B
from django.apps import AppConfig
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class TournamentsConfig(AppConfig):
|
|
name = 'tournaments'
|
|
default_auto_field = 'django.db.models.BigAutoField'
|
|
|
|
def ready(self):
|
|
import tournaments.signals # This will ensure the signals are registered
|
|
# Start background tasks in production
|
|
# Schedule background tasks on startup
|
|
from django.conf import settings
|
|
# Prevent running during database migrations or tests
|
|
from django.core.management import call_command
|
|
try:
|
|
# Only schedule in production
|
|
if not settings.DEBUG:
|
|
# Use the management command to schedule tasks
|
|
call_command('schedule_tasks')
|
|
except Exception as e:
|
|
logger.error(f"Failed to schedule background tasks: {e}")
|
|
|