Files
012-kaopeilian/backend/start.sh
111 998211c483 feat: 初始化考培练系统项目
- 从服务器拉取完整代码
- 按框架规范整理项目结构
- 配置 Drone CI 测试环境部署
- 包含后端(FastAPI)、前端(Vue3)、管理端

技术栈: Vue3 + TypeScript + FastAPI + MySQL
2026-01-24 19:33:28 +08:00

65 lines
1.6 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.
#!/bin/bash
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}考培练系统后端启动脚本${NC}"
echo "================================"
# 检查Python版本
echo -e "${YELLOW}检查Python版本...${NC}"
python_version=$(python3 --version 2>&1)
if [[ $? -eq 0 ]]; then
echo -e "${GREEN}$python_version${NC}"
else
echo -e "${RED}✗ Python3未安装${NC}"
exit 1
fi
# 检查虚拟环境
if [ ! -d "venv" ]; then
echo -e "${YELLOW}创建虚拟环境...${NC}"
python3 -m venv venv
fi
# 激活虚拟环境
echo -e "${YELLOW}激活虚拟环境...${NC}"
source venv/bin/activate
# 安装依赖
echo -e "${YELLOW}安装依赖...${NC}"
pip install -q -r requirements/base.txt
# 检查.env文件
if [ ! -f ".env" ]; then
echo -e "${YELLOW}创建.env文件...${NC}"
cp .env.example .env
echo -e "${GREEN}✓ 已创建.env文件请根据需要修改配置${NC}"
fi
# 检查数据库连接
echo -e "${YELLOW}检查数据库连接...${NC}"
python -c "
import os
from dotenv import load_dotenv
load_dotenv()
db_url = os.getenv('DATABASE_URL', '')
if 'mysql' in db_url:
print('✓ 数据库配置已设置')
else:
print('⚠ 请检查数据库配置')
" 2>/dev/null
# 启动服务
echo -e "${GREEN}启动开发服务器...${NC}"
echo "================================"
echo -e "API文档: ${GREEN}http://localhost:8000/api/docs${NC}"
echo -e "健康检查: ${GREEN}http://localhost:8000/health${NC}"
echo "================================"
# 启动uvicorn
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000