补充部署脚本netstat端口检测

This commit is contained in:
wkc
2026-04-01 10:47:40 +08:00
parent 3ce3c438a9
commit f8b2bf2afc
3 changed files with 66 additions and 2 deletions

View File

@@ -65,7 +65,11 @@ require_port_command() {
return 0
fi
log_error "缺少端口检测命令: ss 或 lsof"
if command -v netstat >/dev/null 2>&1; then
return 0
fi
log_error "缺少端口检测命令: ss、lsof 或 netstat"
exit 1
}
@@ -177,7 +181,12 @@ is_port_listening() {
return $?
fi
lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1
if command -v lsof >/dev/null 2>&1; then
lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1
return $?
fi
netstat -an 2>/dev/null | grep -E "[\\.:]$port[[:space:]].*LISTEN" >/dev/null 2>&1
}
is_managed_backend_pid() {