mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
40 lines
1.6 KiB
Python
40 lines
1.6 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", "Subscriptions", "--noinput"],
|
|
["python", "manage.py", "makemigrations", "GestionNotification", "--noinput"],
|
|
["python", "manage.py", "makemigrations", "GestionMessagerie", "--noinput"],
|
|
["python", "manage.py", "makemigrations", "Auth", "--noinput"],
|
|
["python", "manage.py", "makemigrations", "School", "--noinput"],
|
|
["python", "manage.py", "migrate", "--noinput"],
|
|
["python", "manage.py", "init_payment_plans"],
|
|
["python", "manage.py", "init_payment_modes"],
|
|
["python", "manage.py", "init_data"]
|
|
]
|
|
|
|
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() |