- Updated the PVC models in the database and adjusted the tests accordingly to reflect the new model counts and codes. - Removed deprecated models from the JSON data for PVC systems. - Added new GLB models for "scorrevole_sf_3_ante" and "scorrevole_sf_4_ante". - Enhanced the development scripts to streamline the build process for both frontends. - Updated documentation to reflect changes in the development environment and deployment process. - Improved the styling of texture radio options for better visibility. - Fixed URL handling in the configurator to ensure proper routing and API calls.
91 lines
2.8 KiB
Bash
Executable File
91 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Avvia l'ambiente di sviluppo completo (vedi docs/AVVIO_LOCALE.md). Un solo server, Laravel su
|
|
# http://localhost:8000, che serve API, admin e i due frontend compilati in backoffice/public:
|
|
# - configuratore 3D -> http://localhost:8000/configuratore/
|
|
# - app cliente (preventivo) -> http://localhost:8000/preventivo/
|
|
# I frontend sono ricompilati a ogni modifica (vite build --watch): ricaricare la pagina per vederle.
|
|
# Ctrl+C ferma tutti i servizi.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
|
BACKOFFICE="$ROOT/backoffice"
|
|
CLIENTE="$BACKOFFICE/cliente"
|
|
|
|
port_in_use() { lsof -nP -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1; }
|
|
|
|
# --- Controlli preliminari ---------------------------------------------------
|
|
for cmd in php pnpm lsof; do
|
|
command -v "$cmd" >/dev/null || { echo "Errore: '$cmd' non trovato nel PATH." >&2; exit 1; }
|
|
done
|
|
|
|
if ! port_in_use 3306; then
|
|
echo "Errore: MySQL non risponde sulla porta 3306. Avvialo (es. da Herd) e riprova." >&2
|
|
exit 1
|
|
fi
|
|
|
|
for port in 8000; do
|
|
if port_in_use "$port"; then
|
|
echo "Errore: la porta $port è già occupata:" >&2
|
|
lsof -nP -iTCP:"$port" -sTCP:LISTEN >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
[ -d "$BACKOFFICE/vendor" ] || (cd "$BACKOFFICE" && composer install)
|
|
[ -d "$CLIENTE/node_modules" ] || (cd "$CLIENTE" && pnpm install)
|
|
[ -d "$ROOT/node_modules" ] || (cd "$ROOT" && pnpm install)
|
|
|
|
# --- Avvio servizi -----------------------------------------------------------
|
|
PIDS=()
|
|
|
|
# Termina un processo e tutti i suoi discendenti (pnpm -> vite, artisan serve -> php -S).
|
|
kill_tree() {
|
|
local child
|
|
for child in $(pgrep -P "$1" 2>/dev/null); do kill_tree "$child"; done
|
|
kill -TERM "$1" 2>/dev/null || true
|
|
}
|
|
|
|
cleanup() {
|
|
trap - INT TERM EXIT
|
|
echo
|
|
echo "Arresto dei servizi..."
|
|
for pid in "${PIDS[@]}"; do kill_tree "$pid"; done
|
|
wait 2>/dev/null || true
|
|
}
|
|
trap cleanup EXIT
|
|
trap 'exit 0' INT TERM
|
|
|
|
# Esegue un comando in una cartella prefissando ogni riga di output con un'etichetta.
|
|
run() {
|
|
local label="$1" dir="$2"; shift 2
|
|
(cd "$dir" && exec "$@") > >(sed -u "s/^/[$label] /") 2>&1 &
|
|
PIDS+=($!)
|
|
}
|
|
|
|
run "laravel" "$BACKOFFICE" php artisan serve --port=8000
|
|
run "cliente" "$CLIENTE" pnpm build --watch
|
|
run "config " "$ROOT" pnpm build --watch
|
|
|
|
cat <<EOF
|
|
|
|
Servizi in avvio (attendere la prima build dei frontend):
|
|
Configuratore http://localhost:8000/configuratore/?sistema=pvc&type=finestra_2_ante
|
|
App cliente http://localhost:8000/preventivo/
|
|
API http://localhost:8000/api
|
|
Admin http://localhost:8000/admin (admin@kreiosinfissi.it / password)
|
|
|
|
Ctrl+C per fermare tutto.
|
|
|
|
EOF
|
|
|
|
# Se uno dei servizi termina, ferma anche gli altri.
|
|
while true; do
|
|
for pid in "${PIDS[@]}"; do
|
|
if ! kill -0 "$pid" 2>/dev/null; then
|
|
echo "Un servizio si è fermato, arresto degli altri." >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
sleep 1
|
|
done
|