This commit is contained in:
vet
2026-04-14 11:05:46 +07:00
parent 2e0af83599
commit 6c30dddbbe
4 changed files with 86 additions and 15 deletions

View File

@@ -9,7 +9,12 @@
# =============================================================================
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
load_env 2>/dev/null || true
if [[ -f "$ENV_FILE" ]]; then
set -a
# shellcheck source=/dev/null
source "$ENV_FILE"
set +a
fi
header "服务运行状态"
@@ -45,24 +50,50 @@ print_svc_status "livecloud" ":8080"
print_svc_status "livestream" ":8888"
print_svc_status "build-server" ":8281"
# ── Nginx API / WebSocket 网关 ─────────────────────────────────────────────────
echo ""
echo -e "${BOLD}[ Nginx 网关PC API / WebSocket]${NC}"
if command -v curl &>/dev/null && [[ -n "${PC_BACKEND_ORIGIN:-}" ]]; then
PC_BACKEND_ORIGIN="${PC_BACKEND_ORIGIN%/}"
if curl -fsS --max-time 3 "${PC_BACKEND_ORIGIN}/nginx-health" >/dev/null 2>&1; then
printf " ${GREEN}${NC} %-14s %s\n" "nginx-health" "${PC_BACKEND_ORIGIN}/nginx-health"
else
printf " ${RED}${NC} %-14s %s\n" "nginx-health" "${PC_BACKEND_ORIGIN}/nginx-health 不可达"
echo " 请执行: sudo ./deploy-test/00-init-tools.sh nginx并确认安全组/防火墙放行 TCP 80"
fi
gateway_host=$(printf '%s' "$PC_BACKEND_ORIGIN" | sed -E 's#^https?://([^/]+).*#\1#')
if [[ "$PC_BACKEND_ORIGIN" == https://* ]]; then
default_ws_url="wss://${gateway_host}/msg_gateway"
else
default_ws_url="ws://${gateway_host}/msg_gateway"
fi
echo " PC WebSocket: ${PC_VITE_WS_URL:-$default_ws_url}"
else
printf " ${YELLOW}${NC} %-14s %s\n" "nginx-health" "跳过(未安装 curl 或未设置 PC_BACKEND_ORIGIN"
fi
# ── 前端服务 ─────────────────────────────────────────────────────────────────
echo ""
echo -e "${BOLD}[ 前端开发服务器 ]${NC}"
declare -A FE_PORT_MAP=(
[pc]="5173 (yarn dev:web)"
[meetingh5]="5188"
[h5]="3003"
[cms]="8001"
[build-cms]="8002"
[build-down]="8003"
)
fe_port_desc() {
case "$1" in
pc) echo "5173 (yarn dev:web)" ;;
meetingh5) echo "5188" ;;
h5) echo "3003" ;;
cms) echo "8001" ;;
build-cms) echo "8002" ;;
build-down) echo "8003" ;;
*) echo "?" ;;
esac
}
for fe in pc meetingh5 h5 cms build-cms build-down; do
pidfile="$PID_DIR/fe-${fe}.pid"
logfile="$LOG_DIR/fe-${fe}.log"
port_desc="$(fe_port_desc "$fe")"
if [[ -f "$pidfile" ]] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then
printf " ${GREEN}${NC} %-14s PID=%-7s :%s\n" "$fe" "$(cat "$pidfile")" "${FE_PORT_MAP[$fe]}"
printf " ${GREEN}${NC} %-14s PID=%-7s :%s\n" "$fe" "$(cat "$pidfile")" "$port_desc"
else
printf " ${RED}${NC} %-14s 未运行 :%s\n" "$fe" "${FE_PORT_MAP[$fe]}"
printf " ${RED}${NC} %-14s 未运行 :%s\n" "$fe" "$port_desc"
fi
done