From 5f1d2d79ce00e56660f1a94e270526080b053ec4 Mon Sep 17 00:00:00 2001 From: kang Date: Mon, 25 May 2026 16:03:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start-all.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 start-all.sh diff --git a/start-all.sh b/start-all.sh new file mode 100755 index 0000000..f186435 --- /dev/null +++ b/start-all.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BACKEND_DIR="$ROOT_DIR/lotterLaravel" +API_URL="http://127.0.0.1:8000" +VITE_URL="http://localhost:5173" +REVERB_URL="ws://127.0.0.1:8080" +BACKEND_PORTS=(8000 8080 5173 5174) + +# 只清理后端相关端口,避免影响手动启动的两个前端 +stop_backend_listeners() { + local signal=$1 + for port in "${BACKEND_PORTS[@]}"; do + local pids + pids=$(lsof -nP -iTCP:"$port" -sTCP:LISTEN -t 2>/dev/null || true) + if [[ -n "$pids" ]]; then + echo "Stopping backend port $port (PIDs: $pids)" + # shellcheck disable=SC2086 + kill $signal $pids 2>/dev/null || true + fi + done +} + +stop_backend_listeners TERM +sleep 1 +stop_backend_listeners -9 + +pids=() +cleanup() { + trap - INT TERM EXIT + if ((${#pids[@]})); then + kill "${pids[@]}" 2>/dev/null || true + fi +} +trap cleanup INT TERM EXIT + +echo "Starting backend local stack..." +echo " - Laravel API : $API_URL" +echo " - Vite assets : $VITE_URL" +echo " - Reverb WS : $REVERB_URL" +echo + +echo "Starting backend (Laravel + queue + reverb + schedule + vite) …" +( + cd "$BACKEND_DIR" + composer run dev:realtime +) & +pids+=("$!") + +echo +echo "Backend services are launching. Press Ctrl+C to stop them." +echo + +# wait -n needs Bash 4.3+; macOS /bin/bash is 3.2 +wait "${pids[@]}" +exit_code=$? +cleanup +exit "$exit_code"