This commit is contained in:
vet
2026-04-14 11:26:03 +07:00
parent a5c6161b71
commit 1e39e41c9d
2 changed files with 36 additions and 0 deletions

View File

@@ -278,4 +278,39 @@ pc_check_nginx_gateway() {
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
pc_probe_msg_gateway "$o"
}
pc_probe_msg_gateway() {
local o="${1:-${PC_BACKEND_ORIGIN:-}}"
o="${o%/}"
[[ -z "$o" ]] && return 0
if ! command -v curl &>/dev/null; then
return 0
fi
local local_code public_code tmp_body
tmp_body="${TMPDIR:-/tmp}/openim-msggateway-probe.$$"
local_code=$(curl -sS -o "$tmp_body" -w "%{http_code}" --max-time 3 \
"http://127.0.0.1:10001/msg_gateway" 2>/dev/null || true)
if [[ "$local_code" == "000" ]]; then
warn " MsgGateway 本机不可达: http://127.0.0.1:10001/msg_gateway请确认 openim-server 正在监听 :10001"
else
success " MsgGateway 本机可达: http://127.0.0.1:10001/msg_gateway (HTTP ${local_code},无 token 返回错误属正常)"
fi
public_code=$(curl -sS -o "$tmp_body" -w "%{http_code}" --max-time 3 \
"${o}/msg_gateway" 2>/dev/null || true)
if [[ "$public_code" == "000" ]]; then
warn " MsgGateway Nginx 入口不可达: ${o}/msg_gateway"
elif [[ "$public_code" == "502" || "$public_code" == "503" || "$public_code" == "504" ]]; then
warn " MsgGateway Nginx 入口返回 HTTP ${public_code}: ${o}/msg_gatewayNginx 到 127.0.0.1:10001 可能不通)"
else
success " MsgGateway Nginx 入口可达: ${o}/msg_gateway (HTTP ${public_code},无 token 返回错误属正常)"
fi
rm -f "$tmp_body"
}

View File

@@ -72,6 +72,7 @@ if command -v curl &>/dev/null && [[ -n "${PC_BACKEND_ORIGIN:-}" ]]; then
echo " PC Chat API: ${PC_VITE_CHAT_URL:-${PC_BACKEND_ORIGIN}/api/chat}"
echo " PC Admin API: ${PC_VITE_ADMIN_URL:-${PC_BACKEND_ORIGIN}/api/admin}"
echo " PC WebSocket: ${PC_VITE_WS_URL:-$default_ws_url}"
pc_probe_msg_gateway "$PC_BACKEND_ORIGIN"
else
printf " ${YELLOW}${NC} %-14s %s\n" "nginx-health" "跳过(未安装 curl 或未设置 PC_BACKEND_ORIGIN"
fi