GooDrive/start.sh
Louis Mazin ef5b14d084 nice
2026-10-14 00:08:24 +02:00

30 lines
832 B
Bash

#!/usr/bin/env bash
set -euo pipefail
cd /home/container/backend
# Lors du premier démarrage, laisser à la base le temps de devenir disponible.
tries=0
until python manage.py migrate --noinput; do
tries=$((tries+1))
if ((tries >= 30)); then
echo "Impossible d'appliquer les migrations après 30 tentatives." >&2
exit 1
fi
sleep 2
done
python manage.py ensure_admin
python manage.py runserver 0.0.0.0:1029 &
backend_pid=$!
cd /home/container/frontend
export VITE_API_PROXY_TARGET="${VITE_API_PROXY_TARGET:-http://127.0.0.1:1029}"
npm run dev -- --host 0.0.0.0 --port 1028 &
frontend_pid=$!
cleanup() {
kill "$backend_pid" "$frontend_pid" 2>/dev/null || true
wait "$backend_pid" "$frontend_pid" 2>/dev/null || true
}
trap cleanup EXIT SIGINT SIGTERM
wait -n "$backend_pid" "$frontend_pid"