77 lines
3.9 KiB
Bash
Executable File
77 lines
3.9 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
# ── FRONTEND ──────────────────────────────────────────
|
|
export FRONT_PORT=$FRONT_PORT
|
|
yarn --cwd /app/frontend dev --turbo -p "$FRONT_PORT" &
|
|
echo $! > /app/pids/frontend.pid
|
|
|
|
# ── BACKEND ───────────────────────
|
|
yarn --cwd /app/backend start &
|
|
echo $! > /app/pids/backend.pid
|
|
|
|
# ── Waiting for frontend and backend ───────────────────────
|
|
echo '⌛ Waiting for frontend…'
|
|
until nc -z localhost "$FRONT_PORT"; do sleep 2; done
|
|
echo '✔ Frontend is up.'
|
|
|
|
echo '⌛ Giving frontend a moment to compile routes...'
|
|
sleep 5
|
|
# ---------------------
|
|
|
|
echo '⌛ Waiting for backend…'
|
|
until nc -z localhost "$BACKEND_PORT"; do sleep 2; done
|
|
echo '✔ Backend is up.'
|
|
|
|
# ── APP-SHELL ──────────────────────────────────────────
|
|
export APP_SHELL_PORT=4000
|
|
echo '🚀 Starting app-shell…'
|
|
yarn --cwd /app/app-shell start &
|
|
APP_SHELL_PID=$!
|
|
echo $APP_SHELL_PID > /app/pids/app-shell.pid
|
|
|
|
echo '⌛ Waiting for app-shell to be ready...'
|
|
|
|
until nc -z localhost "$APP_SHELL_PORT"; do sleep 2; done
|
|
echo '✔ App-shell is listening on port.'
|
|
|
|
sleep 10
|
|
echo '✔ App-shell is likely fully initialized.'
|
|
|
|
# ── PAGE WARMING (in background) ──────────────────────
|
|
(
|
|
echo '🔥 Warming specific critical pages first…'
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${FRONT_PORT}/login" || echo "✖ skipped /login (curl failed)"
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${FRONT_PORT}/dashboard" || echo "✖ skipped /dashboard (curl failed)"
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${FRONT_PORT}/" || echo "✖ skipped / (curl failed)"
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${FRONT_PORT}/users/users-list/" || echo "✖ skipped /users/users-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/users/users-list/" || echo "✖ skipped /users/users-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/budgets/budgets-list/" || echo "✖ skipped /budgets/budgets-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/guests/guests-list/" || echo "✖ skipped /guests/guests-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/schedules/schedules-list/" || echo "✖ skipped /schedules/schedules-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/vendors/vendors-list/" || echo "✖ skipped /vendors/vendors-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/venues/venues-list/" || echo "✖ skipped /venues/venues-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/roles/roles-list/" || echo "✖ skipped /roles/roles-list/ (curl failed)"
|
|
|
|
curl -L -s -o /dev/null -w "\n✔ warmed %{url_effective} %{http_code}\n" "http://localhost:${$FRONT_PORT}/permissions/permissions-list/" || echo "✖ skipped /permissions/permissions-list/ (curl failed)"
|
|
|
|
echo '🚀 Warmup script finished.'
|
|
) &
|
|
|
|
# ── Nginx PID 1 ──────────────────
|
|
echo '🚀 Starting Nginx…'
|
|
nginx -g "daemon off;" &
|
|
NGINX_PID=$!
|
|
|
|
trap 'kill $(jobs -p)' TERM INT
|
|
|
|
wait "$NGINX_PID"
|
|
|