- Add start.sh/start.bat for one-click startup (backend + frontend) - Add stop.sh/stop.bat for stopping all services - Add restart.sh for restarting services - Add status.sh for checking service status - Add Makefile with convenient management commands - Add comprehensive documentation (ONE_CLICK_START.md) - Update README with one-click startup instructions Features: - Automatic environment checking (venv, node_modules) - Process management with PID tracking - Unified log management (logs/*.log) - Health checking after startup - Support for Linux, macOS, and Windows - No more need for multiple terminal windows Usage: ./start.sh # Start all services ./stop.sh # Stop all services ./status.sh # Check service status ./restart.sh # Restart services make start # Alternative using Makefile Benefits: - One command instead of multiple terminals - Automatic environment validation - Centralized logging - Process lifecycle management - Developer-friendly output messages
97 lines
2.5 KiB
Makefile
97 lines
2.5 KiB
Makefile
.PHONY: start stop restart status logs clean install help
|
|
|
|
# ERP AI Assistant Makefile
|
|
|
|
# 默认目标
|
|
.DEFAULT_GOAL := help
|
|
|
|
# 帮助信息
|
|
help:
|
|
@echo "ERP AI Assistant - 管理命令"
|
|
@echo ""
|
|
@echo "使用方法: make [命令]"
|
|
@echo ""
|
|
@echo "可用命令:"
|
|
@echo " start 启动项目(后端 + 前端)"
|
|
@echo " stop 停止项目"
|
|
@echo " restart 重启项目"
|
|
@echo " status 查看服务状态"
|
|
@echo " logs 查看日志(后端和前端)"
|
|
@echo " logs-backend 查看后端日志"
|
|
@echo " logs-frontend 查看前端日志"
|
|
@echo " install 安装所有依赖"
|
|
@echo " clean 清理日志和临时文件"
|
|
@echo " test 运行测试"
|
|
@echo ""
|
|
|
|
# 启动项目
|
|
start:
|
|
@./start.sh
|
|
|
|
# 停止项目
|
|
stop:
|
|
@./stop.sh
|
|
|
|
# 重启项目
|
|
restart:
|
|
@./restart.sh
|
|
|
|
# 查看状态
|
|
status:
|
|
@./status.sh
|
|
|
|
# 查看所有日志
|
|
logs:
|
|
@echo "查看后端和前端日志 (按 Ctrl+C 退出)..."
|
|
@tail -f logs/backend.log logs/frontend.log
|
|
|
|
# 查看后端日志
|
|
logs-backend:
|
|
@echo "查看后端日志 (按 Ctrl+C 退出)..."
|
|
@tail -f logs/backend.log
|
|
|
|
# 查看前端日志
|
|
logs-frontend:
|
|
@echo "查看前端日志 (按 Ctrl+C 退出)..."
|
|
@tail -f logs/frontend.log
|
|
|
|
# 安装依赖
|
|
install:
|
|
@echo "安装后端依赖..."
|
|
cd backend && python3 -m venv venv && . venv/bin/activate && pip install -r requirements.txt
|
|
@echo "安装前端依赖..."
|
|
cd frontend && npm install
|
|
@echo "✅ 依赖安装完成"
|
|
|
|
# 清理
|
|
clean:
|
|
@echo "清理日志和临时文件..."
|
|
rm -rf logs/*.log logs/pids.txt
|
|
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
|
find . -type f -name "*.pyc" -delete
|
|
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
|
|
find . -type d -name "node_modules" -prune -o -type d -name ".cache" -exec rm -rf {} + 2>/dev/null || true
|
|
@echo "✅ 清理完成"
|
|
|
|
# 运行测试
|
|
test:
|
|
@echo "运行后端测试..."
|
|
cd backend && . venv/bin/activate && pytest tests/ -v --cov=app
|
|
@echo "✅ 测试完成"
|
|
|
|
# 开发模式(前台运行,方便调试)
|
|
dev:
|
|
@echo "开发模式启动..."
|
|
@echo "后端日志将输出到此终端"
|
|
@./stop.sh
|
|
@cd backend && . venv/bin/activate && python -m app.main & BACKEND_PID=$$!; \
|
|
cd ../frontend && npm run dev & FRONTEND_PID=$$!; \
|
|
echo ""; \
|
|
echo "服务已启动:"; \
|
|
echo " 前端: http://localhost:5173"; \
|
|
echo " 后端: http://localhost:8000"; \
|
|
echo ""; \
|
|
echo "PID: 后端=$$BACKEND_PID, 前端=$$FRONTEND_PID"; \
|
|
echo "按 Ctrl+C 停止所有服务..."; \
|
|
trap "kill $$BACKEND_PID $$FRONTEND_PID 2>/dev/null; exit" INT TERM; \
|
|
wait
|