Files
live-hub-py/start_web.sh
T
yml2213 db384701a9 fix(security): JWT密钥与默认账号改用环境变量,清理泄露凭据
- JWT_SECRET_KEY 改从环境变量读取,未设置时使用临时随机密钥并告警
- 默认管理员账号密码改用 ADMIN_USERNAME/ADMIN_PASSWORD 环境变量配置
- 移除登录页及启动/部署脚本中的默认密码明文提示
- docker-compose.yml 添加环境变量支持(从 .env 文件读取)
- 新增 .env.example 配置文档,.gitignore 添加 .env 规则
- git rm --cached 清理已追踪的 data/accounts.json 和 data/cookies/敏感文件
2026-06-23 06:42:37 +08:00

63 lines
1.5 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
set -e
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT_DIR"
PYTHON="$ROOT_DIR/.venv/bin/python"
FRONTEND_DIR="$ROOT_DIR/web/frontend"
BACKEND_PORT=8000
FRONTEND_PORT=5173
# 检查 Python 虚拟环境
if [ ! -f "$PYTHON" ]; then
echo "❌ 未找到 .venv,正在创建..."
uv venv .venv
uv pip install -e .
fi
# 检查前端依赖
if [ ! -d "$FRONTEND_DIR/node_modules" ]; then
echo "❌ 前端依赖未安装,正在安装..."
cd "$FRONTEND_DIR" && npm install && cd "$ROOT_DIR"
fi
echo ""
echo "=============================="
echo " 斗鱼批量登录 - Web 后台"
echo "=============================="
echo " 后端: http://localhost:$BACKEND_PORT"
echo " 前端: http://localhost:$FRONTEND_PORT"
echo " 默认账号见环境变量 ADMIN_USERNAME/ADMIN_PASSWORD(未设置则为 admin/admin123"
echo " 按 Ctrl+C 停止所有服务"
echo "=============================="
echo ""
# 清理子进程
cleanup() {
echo ""
echo "正在停止服务..."
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null
wait $BACKEND_PID $FRONTEND_PID 2>/dev/null
echo "已停止"
}
trap cleanup EXIT INT TERM
# 启动后端
echo "启动后端 (FastAPI :$BACKEND_PORT)..."
"$PYTHON" -m uvicorn web.backend.main:app --host 0.0.0.0 --port $BACKEND_PORT --reload &
BACKEND_PID=$!
# 等后端就绪
sleep 2
# 启动前端
echo "启动前端 (Vite :$FRONTEND_PORT)..."
cd "$FRONTEND_DIR"
npm run dev -- --port $FRONTEND_PORT --host 0.0.0.0 &
FRONTEND_PID=$!
cd "$ROOT_DIR"
# 等待子进程
wait