|
|
|
|
@ -1,23 +1,9 @@ |
|
|
|
|
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}") |
|
|
|
|
|