From 3719d1fcaf08fc8f2c6bbd4394e0437c8700d74d Mon Sep 17 00:00:00 2001 From: vet Date: Tue, 14 Apr 2026 11:32:01 +0700 Subject: [PATCH] test --- common.sh | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/common.sh b/common.sh index 4032f47..b4ec027 100755 --- a/common.sh +++ b/common.sh @@ -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_gateway(Nginx 到 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 告警)" }