Files
PlantAI-rag-new/bioflow_service/restart.sh
T
adminandClaude Fable 5 7037a1d5d8 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>
2026-09-12 18:22:11 +08:00

38 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# restart.sh —— BIOFLOW 服务重启脚本(8098;不触碰生产服务 8090/8091)。
# 零硬编码:venv/python/仓库路径全部从脚本位置推导或环境变量覆盖。
# 用法: restart.sh [python] [port]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PYTHON="${1:-$REPO_ROOT/../plantai-rag-new-venv/bin/python}"
PORT="${2:-8098}"
HOST="${BIOFLOW_BIND_HOST:-127.0.0.1}"
[[ -x "$PYTHON" ]] || { echo "Python not found: $PYTHON" >&2; exit 2; }
APP_MODULE="app.main:app"
PID=""
if command -v lsof >/dev/null 2>&1; then
PID="$(lsof -ti tcp:"$PORT" -sTCP:LISTEN 2>/dev/null || true)"
fi
if [[ -n "$PID" ]]; then
echo "[restart] 停止 8098 旧进程 pid=$PID"
kill $PID 2>/dev/null || true
sleep 2
fi
cd "$SCRIPT_DIR"
# 加载运行时配置(.env 不入 git):pydantic-settings 读 BIOFLOW_ 前缀键,
# 而 services/bioflow/llm.py 直接读 os.environ 的 DOCGEN_LLM_* 裸键——
# 故需 set -a 显式导出(同 bff_restart.sh 的 services/neo4j.py 先例,TL 2026-09-06)
set -a
[ -f .env ] && source .env
set +a
echo "[restart] 启动生信服务 :$PORT($PYTHON)"
nohup "$PYTHON" -m uvicorn "$APP_MODULE" --host "$HOST" --port "$PORT" \
> "$SCRIPT_DIR/bioflow.log" 2>&1 &
echo "[restart] 完成;日志 bioflow_service/bioflow.log"