feat: Implement thread-safe account and statistics management and integrate proxy support for all external requests.

This commit is contained in:
2026-02-13 03:32:27 +08:00
parent 1c58279292
commit ef23318090
12 changed files with 1041 additions and 84 deletions

View File

@@ -44,11 +44,13 @@ echo ""
# ============================================================
info "检查系统依赖..."
# 确保 uv 路径在 PATH 中
export PATH="$HOME/.local/bin:/root/.local/bin:$PATH"
# 安装 uv如果不存在
if ! command -v uv &> /dev/null; then
info "安装 uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
ok "uv 已安装"
else
ok "uv 已存在 ($(uv --version))"
@@ -59,8 +61,16 @@ fi
# ============================================================
info "安装 Python 依赖..."
cd "$APP_DIR"
sudo -u "$RUN_USER" uv sync 2>/dev/null || sudo -u "$RUN_USER" uv pip install -r pyproject.toml 2>/dev/null || true
ok "依赖安装完成"
if uv sync; then
ok "依赖安装完成"
else
warn "uv sync 失败,尝试 uv pip install..."
if uv pip install -r pyproject.toml; then
ok "依赖安装完成 (pip fallback)"
else
err "依赖安装失败,请手动检查"
fi
fi
# ============================================================
# 3. 检查配置文件
@@ -83,7 +93,16 @@ fi
# ============================================================
# 4. 获取 uv 和 python 路径
# ============================================================
UV_PATH="$(sudo -u "$RUN_USER" bash -c 'which uv')"
UV_PATH="$(which uv 2>/dev/null || echo '')"
if [ -z "$UV_PATH" ]; then
# 尝试常见路径
for p in "$HOME/.local/bin/uv" "/root/.local/bin/uv" "/usr/local/bin/uv"; do
if [ -x "$p" ]; then UV_PATH="$p"; break; fi
done
fi
if [ -z "$UV_PATH" ]; then
err "找不到 uv请检查安装是否成功"
fi
info "uv 路径: ${UV_PATH}"
# ============================================================
@@ -119,7 +138,6 @@ SyslogIdentifier=${APP_NAME}
# 安全加固
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=${APP_DIR}
PrivateTmp=true