fix(deploy): restart 脚本 lsof 只取 LISTEN 态进程
2026-09-12 部署实测:lsof -ti tcp:PORT 返回该端口上所有 socket 的 进程——包括 BFF 到 8098/8094 的已建立连接,不只监听者。kill 多行 PID 时旧进程存活、新进程绑定失败静默退出(vstore 报 address already in use;生信 restart 后仍是旧进程)。改 -sTCP:LISTEN 只取监听者, kill 不再加引号(多 PID 需分词)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,12 +15,12 @@ HOST="${BIOFLOW_BIND_HOST:-127.0.0.1}"
|
|||||||
APP_MODULE="app.main:app"
|
APP_MODULE="app.main:app"
|
||||||
PID=""
|
PID=""
|
||||||
if command -v lsof >/dev/null 2>&1; then
|
if command -v lsof >/dev/null 2>&1; then
|
||||||
PID="$(lsof -ti tcp:"$PORT" 2>/dev/null || true)"
|
PID="$(lsof -ti tcp:"$PORT" -sTCP:LISTEN 2>/dev/null || true)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$PID" ]]; then
|
if [[ -n "$PID" ]]; then
|
||||||
echo "[restart] 停止 8098 旧进程 pid=$PID"
|
echo "[restart] 停止 8098 旧进程 pid=$PID"
|
||||||
kill "$PID" 2>/dev/null || true
|
kill $PID 2>/dev/null || true
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ HOST="${VSTORE_BIND_HOST:-127.0.0.1}"
|
|||||||
|
|
||||||
# 杀旧进程([v]store 正则技巧防 pkill 自匹配;端口优先精确)
|
# 杀旧进程([v]store 正则技巧防 pkill 自匹配;端口优先精确)
|
||||||
if command -v lsof >/dev/null 2>&1; then
|
if command -v lsof >/dev/null 2>&1; then
|
||||||
OLD_PID="$(lsof -ti tcp:"$PORT" 2>/dev/null || true)"
|
OLD_PID="$(lsof -ti tcp:"$PORT" -sTCP:LISTEN 2>/dev/null || true)"
|
||||||
[ -n "$OLD_PID" ] && kill "$OLD_PID" 2>/dev/null || true
|
[ -n "$OLD_PID" ] && kill $OLD_PID 2>/dev/null || true
|
||||||
else
|
else
|
||||||
pkill -f "[v]store.api:app" 2>/dev/null || true
|
pkill -f "[v]store.api:app" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user