test
This commit is contained in:
@@ -124,8 +124,10 @@ _start_fe() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
info "启动 ${BOLD}$name${NC} ..."
|
info "启动 ${BOLD}$name${NC} ..."
|
||||||
if [[ "$name" == "pc" ]] && [[ -n "${PC_BACKEND_ORIGIN:-}" ]]; then
|
if [[ "$name" == "pc" ]]; then
|
||||||
info " pc 后端 PC_BACKEND_ORIGIN=${PC_BACKEND_ORIGIN}(注入 VITE_*,不写 pc 目录)"
|
pc_export_vite_backend_env
|
||||||
|
pc_print_vite_backend_env
|
||||||
|
pc_check_nginx_gateway
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 写日志分隔符
|
# 写日志分隔符
|
||||||
|
|||||||
31
common.sh
31
common.sh
@@ -247,3 +247,34 @@ pc_export_vite_backend_env() {
|
|||||||
export VITE_WS_URL="${PC_VITE_WS_URL:-wss://${host}/msg_gateway}"
|
export VITE_WS_URL="${PC_VITE_WS_URL:-wss://${host}/msg_gateway}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pc_print_vite_backend_env() {
|
||||||
|
if [[ -z "${PC_BACKEND_ORIGIN:-}" ]]; then
|
||||||
|
warn " pc 未设置 PC_BACKEND_ORIGIN,将使用 pc/.env 或代码默认地址;WebSocket 可能连错环境"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
info " pc 后端 PC_BACKEND_ORIGIN=${PC_BACKEND_ORIGIN}(注入 VITE_*,不写 pc 目录)"
|
||||||
|
info " VITE_API_URL=${VITE_API_URL:-<empty>}"
|
||||||
|
info " VITE_WS_URL=${VITE_WS_URL:-<empty>}"
|
||||||
|
info " VITE_CHAT_URL=${VITE_CHAT_URL:-<empty>}"
|
||||||
|
info " VITE_USER_URL=${VITE_USER_URL:-<empty>}"
|
||||||
|
}
|
||||||
|
|
||||||
|
pc_check_nginx_gateway() {
|
||||||
|
local o="${PC_BACKEND_ORIGIN:-}"
|
||||||
|
o="${o%/}"
|
||||||
|
[[ -z "$o" ]] && return 0
|
||||||
|
|
||||||
|
if ! command -v curl &>/dev/null; then
|
||||||
|
warn " 未安装 curl,跳过 Nginx 网关检查;请手动访问 ${o}/nginx-health"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if curl -fsS --max-time 3 "${o}/nginx-health" >/dev/null 2>&1; then
|
||||||
|
success " Nginx 网关可达: ${o}/nginx-health"
|
||||||
|
else
|
||||||
|
warn " Nginx 网关不可达: ${o}/nginx-health"
|
||||||
|
warn " PC WebSocket 默认连 ${VITE_WS_URL:-ws://<host>/msg_gateway};请确认已执行 sudo ./deploy-test/00-init-tools.sh nginx,并放行 TCP 80"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
# default_server:纯 IP 访问 http://x.x.x.x/ 时命中本 server(不做 CMS 静态站,仅 API 网关)
|
# default_server:纯 IP 访问 http://x.x.x.x/ 时命中本 server(不做 CMS 静态站,仅 API 网关)
|
||||||
# CMS 开发请用 http://IP:8001(UMI dev)
|
# CMS 开发请用 http://IP:8001(UMI dev)
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
listen [::]:80 default_server;
|
listen [::]:80 default_server;
|
||||||
@@ -64,12 +69,14 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# MsgGateway WebSocket → openim-server :10001
|
# MsgGateway WebSocket → openim-server :10001
|
||||||
location /msg_gateway {
|
location ^~ /msg_gateway {
|
||||||
proxy_pass http://127.0.0.1:10001;
|
proxy_pass http://127.0.0.1:10001;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection $connection_upgrade;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Port $server_port;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|||||||
53
status.sh
53
status.sh
@@ -9,7 +9,12 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
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 "服务运行状态"
|
header "服务运行状态"
|
||||||
|
|
||||||
@@ -45,24 +50,50 @@ print_svc_status "livecloud" ":8080"
|
|||||||
print_svc_status "livestream" ":8888"
|
print_svc_status "livestream" ":8888"
|
||||||
print_svc_status "build-server" ":8281"
|
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 ""
|
||||||
echo -e "${BOLD}[ 前端开发服务器 ]${NC}"
|
echo -e "${BOLD}[ 前端开发服务器 ]${NC}"
|
||||||
declare -A FE_PORT_MAP=(
|
fe_port_desc() {
|
||||||
[pc]="5173 (yarn dev:web)"
|
case "$1" in
|
||||||
[meetingh5]="5188"
|
pc) echo "5173 (yarn dev:web)" ;;
|
||||||
[h5]="3003"
|
meetingh5) echo "5188" ;;
|
||||||
[cms]="8001"
|
h5) echo "3003" ;;
|
||||||
[build-cms]="8002"
|
cms) echo "8001" ;;
|
||||||
[build-down]="8003"
|
build-cms) echo "8002" ;;
|
||||||
)
|
build-down) echo "8003" ;;
|
||||||
|
*) echo "?" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
for fe in pc meetingh5 h5 cms build-cms build-down; do
|
for fe in pc meetingh5 h5 cms build-cms build-down; do
|
||||||
pidfile="$PID_DIR/fe-${fe}.pid"
|
pidfile="$PID_DIR/fe-${fe}.pid"
|
||||||
logfile="$LOG_DIR/fe-${fe}.log"
|
logfile="$LOG_DIR/fe-${fe}.log"
|
||||||
|
port_desc="$(fe_port_desc "$fe")"
|
||||||
if [[ -f "$pidfile" ]] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then
|
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
|
else
|
||||||
printf " ${RED}○${NC} %-14s 未运行 :%s\n" "$fe" "${FE_PORT_MAP[$fe]}"
|
printf " ${RED}○${NC} %-14s 未运行 :%s\n" "$fe" "$port_desc"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user