This commit is contained in:
vet
2026-04-14 11:32:01 +07:00
parent 1e39e41c9d
commit 3719d1fcaf

View File

@@ -287,30 +287,13 @@ pc_probe_msg_gateway() {
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"
local gateway_pid
gateway_pid=$(lsof -ti :10001 2>/dev/null | head -1 || true)
if [[ -n "$gateway_pid" ]]; then
success " MsgGateway 本机端口监听正常: 127.0.0.1:10001 (PID=${gateway_pid})"
else
success " MsgGateway 本机可达: http://127.0.0.1:10001/msg_gateway (HTTP ${local_code},无 token 返回错误属正常)"
warn " MsgGateway 本机端口未监听: 127.0.0.1:10001(请确认 openim-server 已启动)"
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"
info " MsgGateway Nginx 入口: ${o}/msg_gateway不做无 token HTTP 探测,避免在 openim-server.log 中产生 token is empty 告警)"
}