Files
n3wt-school/Back-End/start.py
Luc SORIGNET af0cd1c840 chore: Initial Commit
feat: Gestion des inscriptions [#1]
feat(frontend): Création des vues pour le paramétrage de l'école [#2]
feat: Gestion du login [#6]
fix: Correction lors de la migration des modèle [#8]
feat: Révision du menu principal [#9]
feat: Ajout d'un footer [#10]
feat: Création des dockers compose pour les environnements de
développement et de production [#12]
doc(ci): Mise en place de Husky et d'un suivi de version automatique [#14]
2024-11-18 16:06:21 +01:00

37 lines
1.4 KiB
Python

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", "GestionInscriptions"],
["python", "manage.py", "makemigrations", "GestionNotification"],
["python", "manage.py", "makemigrations", "GestionMessagerie"],
["python", "manage.py", "makemigrations", "GestionLogin"],
["python", "manage.py", "makemigrations", "GestionEnseignants"],
["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()