主要功能更新: - 新增配置管理模块:支持YAML配置文件的在线编辑、验证和保存 - 实现评分规则管理:支持YAML格式评分配置,简化条件配置流程 - 完善前后端通信:优化API路径配置,解决跨域和网络连接问题 - 新增组件架构:AppContent、ConfigManager、ScoringRules、ThreatGraph等核心组件 - 集成js-yaml库:支持前端YAML格式解析和编辑 - 修复UI渲染问题:解决Naive UI组件空值引用和布局问题 技术改进: - 动态API地址配置,支持不同网络环境 - 增强错误处理和空值保护 - 优化表格布局和操作按钮排列 - 完善类型定义和接口规范 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
94 lines
2.8 KiB
Bash
Executable File
94 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# AI SOC Analyst Backend - One-Click Startup Script
|
|
# Usage: ./start_backend.sh
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "🚀 AI SOC Analyst Backend - One-Click Startup"
|
|
echo "=============================================="
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Get script directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
BACKEND_DIR="${SCRIPT_DIR}/backend"
|
|
|
|
echo -e "${BLUE}📂 Project directory: ${SCRIPT_DIR}${NC}"
|
|
|
|
# Check if Python is installed
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo -e "${RED}❌ Python 3 is not installed. Please install Python 3.8+ and try again.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${GREEN}✅ Python 3 found: $(python3 --version)${NC}"
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -f "${BACKEND_DIR}/requirements.txt" ]; then
|
|
echo -e "${RED}❌ Backend requirements.txt not found. Please run this script from the project root.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Create virtual environment if it doesn't exist
|
|
VENV_DIR="${SCRIPT_DIR}/venv"
|
|
if [ ! -d "$VENV_DIR" ]; then
|
|
echo -e "${YELLOW}📦 Creating virtual environment...${NC}"
|
|
python3 -m venv "$VENV_DIR"
|
|
fi
|
|
|
|
# Activate virtual environment
|
|
echo -e "${BLUE}🔧 Activating virtual environment...${NC}"
|
|
source "$VENV_DIR/bin/activate"
|
|
|
|
# Install/upgrade dependencies
|
|
echo -e "${YELLOW}📥 Installing/updating Python dependencies...${NC}"
|
|
pip install --upgrade pip
|
|
pip install -r "${BACKEND_DIR}/requirements.txt"
|
|
|
|
# Check if main.py or api_main.py exists
|
|
MAIN_FILE=""
|
|
if [ -f "${BACKEND_DIR}/app/main.py" ]; then
|
|
MAIN_FILE="${BACKEND_DIR}/app/main.py"
|
|
elif [ -f "${BACKEND_DIR}/app/api_main.py" ]; then
|
|
MAIN_FILE="${BACKEND_DIR}/app/api_main.py"
|
|
else
|
|
echo -e "${RED}❌ No main application file found (main.py or api_main.py)${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${GREEN}✅ Found application file: ${MAIN_FILE}${NC}"
|
|
|
|
# Create uploads directory if it doesn't exist
|
|
UPLOADS_DIR="${BACKEND_DIR}/uploads"
|
|
if [ ! -d "$UPLOADS_DIR" ]; then
|
|
echo -e "${YELLOW}📁 Creating uploads directory...${NC}"
|
|
mkdir -p "$UPLOADS_DIR"
|
|
fi
|
|
|
|
# Set environment variables
|
|
export PYTHONPATH="${BACKEND_DIR}:${PYTHONPATH}"
|
|
|
|
echo ""
|
|
echo -e "${GREEN}🎉 Setup complete! Starting the server...${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}📍 Backend API will be available at: ${GREEN}http://localhost:8000${NC}"
|
|
echo -e "${BLUE}📖 API documentation at: ${GREEN}http://localhost:8000/docs${NC}"
|
|
echo -e "${BLUE}📚 Alternative docs at: ${GREEN}http://localhost:8000/redoc${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}⚡ Press Ctrl+C to stop the server${NC}"
|
|
echo ""
|
|
|
|
# Start the server
|
|
cd "$BACKEND_DIR"
|
|
if command -v uvicorn &> /dev/null; then
|
|
uvicorn app.api_main:app --host 0.0.0.0 --port 8000 --reload
|
|
else
|
|
# Fallback to running Python directly
|
|
python3 app/main.py
|
|
fi |