Motivations: - Fix 502 en prod via build multi-pages et routes stables - Stabilize IndexedDB (création stores) et faucet obligatoire - Déploiement robuste: port 3004 garanti et logs Modifications: - Vite: inputs multi-pages, alias npm deploy:front - Router/redirects: chemins - Pages setup: URLs corrigées, suppression log faucet disabled - DB: bump version à 5, upgrade crée stores manquants - Script: scripts/deploy_front.sh (kill 3004, clean, build, start bg) - Lint: perf monitor param non utilisé, warnings corrigés Page affectées: - vite.config.ts, src/router.ts - src/pages/* (home, pairing, block-sync, wallet-setup, security-setup) - src/services/* (database-config, performance-monitor) - package.json, scripts/deploy_front.sh
69 lines
1.9 KiB
Bash
Executable File
69 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
LOG_DIR="$PROJECT_ROOT/logs"
|
|
PID_FILE="$LOG_DIR/ihm_client_dev3.front.pid"
|
|
LOG_FILE="$LOG_DIR/ihm_client_dev3.front.log"
|
|
PORT=3004
|
|
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
echo "[deploy] Ensuring nothing listens on :$PORT..."
|
|
if ss -ltnp | grep -q ":$PORT"; then
|
|
# Extract PID(s) for the port
|
|
PIDS=$(ss -ltnp | awk -v p=":$PORT" '$0 ~ p {print $NF}' | sed -E 's/.*pid=([0-9]+).*/\1/' | sort -u)
|
|
for PID in $PIDS; do
|
|
if [[ "$PID" =~ ^[0-9]+$ ]]; then
|
|
echo "[deploy] Killing PID $PID on port $PORT"
|
|
kill -TERM "$PID" || true
|
|
# Wait up to 10s for process to exit
|
|
for i in {1..10}; do
|
|
if ! ps -p "$PID" >/dev/null 2>&1; then break; fi
|
|
sleep 1
|
|
done
|
|
if ps -p "$PID" >/dev/null 2>&1; then
|
|
echo "[deploy] Force killing PID $PID"
|
|
kill -KILL "$PID" || true
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
echo "[deploy] Cleaning Vite caches and previous dist..."
|
|
rm -rf "$PROJECT_ROOT/node_modules/.vite" "$PROJECT_ROOT/.vite" "$PROJECT_ROOT/dist"
|
|
|
|
echo "[deploy] Building production bundle..."
|
|
cd "$PROJECT_ROOT"
|
|
npm run build
|
|
|
|
echo "[deploy] Starting Vite dev server on :$PORT (non-bloquant) ..."
|
|
if [[ -f "$PID_FILE" ]]; then
|
|
# Clean stale PID file if any
|
|
OLD_PID=$(cat "$PID_FILE" || true)
|
|
if [[ -n "${OLD_PID}" ]] && ps -p "$OLD_PID" >/dev/null 2>&1; then
|
|
echo "[deploy] Previous PID $OLD_PID still running, terminating"
|
|
kill -TERM "$OLD_PID" || true
|
|
fi
|
|
rm -f "$PID_FILE"
|
|
fi
|
|
|
|
nohup npm run start >"$LOG_FILE" 2>&1 &
|
|
NEW_PID=$!
|
|
echo "$NEW_PID" > "$PID_FILE"
|
|
|
|
echo "[deploy] Launched PID $NEW_PID. Tail logs: tail -f $LOG_FILE"
|
|
|
|
echo "[deploy] Verifying port $PORT availability..."
|
|
for i in {1..10}; do
|
|
if ss -ltnp | grep -q ":$PORT"; then
|
|
echo "[deploy] OK: port $PORT is listening."
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "[deploy] ERROR: port $PORT not listening after start. Check $LOG_FILE"
|
|
exit 1
|