Files
vps-manager/run.sh
T
gouki dd79d24b2b fix(run.sh): venv 初始化追加安装 requirements-dev.txt
本地/手动启动入口 run.sh 在创建 .venv 时一并装 pytest,使 .qoder/rules 里的 .venv/bin/python -m pytest 开箱即用、测试环境可复现。生产由 systemd 直接拉起 uvicorn,setup.sh/update.sh 仍只装 requirements.txt,dev 依赖不会带上线。
2026-10-12 21:31:25 +00:00

28 lines
1.3 KiB
Bash
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
# vps-manager 启动脚本(部署于 Tailscale cc1 节点 100.89.0.11)
# 用法:./run.sh # 前台启动
# ./run.sh --reload # 开发模式(热重载)
cd "$(dirname "$0")" || exit 1
if [ ! -d ".venv" ]; then
echo "[init] 创建虚拟环境并安装依赖(含测试依赖)..."
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
# 测试依赖(pytest)随本地 venv 一并装好,保证 .qoder/rules 里的
# `.venv/bin/python -m pytest` 开箱即用、测试环境可复现。
# 生产不走本脚本(systemd 直接拉起 uvicorn),setup.sh/update.sh 也只装
# requirements.txt,故 dev 依赖不会带上线。
.venv/bin/pip install -r requirements-dev.txt
fi
# 监听地址/端口可用环境变量覆盖(HOST=127.0.0.1 ./run.sh)。
# 默认 0.0.0.0 是为了让其他 VPS 上的 Agent 能直连 100.89.0.11:8000 上报;
# 若所有 Agent 都改走 tailscale serve 的 HTTPS 地址,HOST=127.0.0.1 更安全:
# GET 接口对 tailnet/本机零鉴权,绑公网 IP 时资产清单会被任意读取。
# 注:生产由 systemd 拉起,绑定地址在 deploy/vps-manager.service 的 ExecStart 里。
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8000}"
exec .venv/bin/uvicorn app.main:app --host "$HOST" --port "$PORT" "$@"