import subprocess import os def run_command(command): process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate(input=b"y\n") if process.returncode != 0: print(f"Error running command: {' '.join(command)}") print(f"stdout: {stdout.decode()}") print(f"stderr: {stderr.decode()}") return process.returncode commands = [ ["python", "manage.py", "collectstatic", "--noinput"], ["python", "manage.py", "flush", "--noinput"], ["python", "manage.py", "makemigrations", "Subscriptions"], ["python", "manage.py", "makemigrations", "GestionNotification"], ["python", "manage.py", "makemigrations", "GestionMessagerie"], ["python", "manage.py", "makemigrations", "Auth"], ["python", "manage.py", "makemigrations", "School"], ["python", "manage.py", "migrate"] ] for command in commands: if run_command(command) != 0: exit(1) # Lancer les processus en parallèle processes = [ subprocess.Popen(["python", "manage.py", "runserver", "0.0.0.0:8080"]), subprocess.Popen(["celery", "-A", "N3wtSchool", "worker", "--loglevel=info"]), subprocess.Popen(["celery", "-A", "N3wtSchool", "beat", "--loglevel=info", "--scheduler", "django_celery_beat.schedulers:DatabaseScheduler"]) ] # Attendre la fin des processus for process in processes: process.wait()