#!/bin/sh set -e # ── FRONTEND ────────────────────────────────────────── export FRONT_PORT=${FRONT_PORT:-3001} yarn --cwd /app/frontend dev --turbopack --turbo -p "$FRONT_PORT" & echo $! > /app/pids/frontend.pid # ── BACKEND ─────────────────────── export BACKEND_PORT=${BACKEND_PORT:-3000} npm --prefix /app/backend run start & echo $! > /app/pids/backend.pid # ── APP-SHELL ────────────────────────────────────────── export APP_SHELL_PORT=${APP_SHELL_PORT:-4000} yarn --cwd /app/app-shell start & APP_SHELL_PID=$! echo $APP_SHELL_PID > /app/pids/app-shell.pid echo '⌛ Waiting for backend to be ready...' until nc -z localhost "$BACKEND_PORT"; do sleep 2; done echo '✔ Backend is listening on port.' sleep 5 echo '⌛ Waiting for app-shell to be ready (including Git initialization)...' until nc -z localhost "$APP_SHELL_PORT"; do sleep 2; done echo '✔ App-shell is fully ready and listening on port.' echo '⌛ Waiting for frontend to be ready...' until nc -z localhost "$FRONT_PORT"; do sleep 2; done echo '✔ Frontend is listening on port.' echo '⌛ Giving frontend time for initial compilation and route setup...' sleep 5 echo '✔ Frontend is likely ready for traffic.' # ── PAGE WARMING (in background) ────────────────────── # ── Nginx PID 1 ────────────────── echo '🚀 Starting Nginx…' nginx -g "daemon off;" & NGINX_PID=$! trap 'kill $(jobs -p)' TERM INT wait "$NGINX_PID"