- 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
70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# ERP AI Assistant - 状态检查脚本
|
|
|
|
# 颜色定义
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# 项目根目录
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PID_FILE="$PROJECT_ROOT/logs/pids.txt"
|
|
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo -e "${BLUE} ERP AI Assistant - 服务状态${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo ""
|
|
|
|
# 检查后端
|
|
echo -e "${YELLOW}后端服务:${NC}"
|
|
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
|
|
HEALTH=$(curl -s http://localhost:8000/health)
|
|
echo -e " 状态: ${GREEN}✓ 运行中${NC}"
|
|
echo -e " 地址: http://localhost:8000"
|
|
echo -e " API文档: http://localhost:8000/docs"
|
|
echo -e " 健康检查: $HEALTH"
|
|
else
|
|
echo -e " 状态: ${RED}✗ 未运行${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# 检查前端
|
|
echo -e "${YELLOW}前端服务:${NC}"
|
|
if curl -s http://localhost:5173 > /dev/null 2>&1; then
|
|
echo -e " 状态: ${GREEN}✓ 运行中${NC}"
|
|
echo -e " 地址: http://localhost:5173"
|
|
else
|
|
echo -e " 状态: ${RED}✗ 未运行${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# 显示进程信息
|
|
if [ -f "$PID_FILE" ]; then
|
|
echo -e "${YELLOW}进程信息:${NC}"
|
|
while read pid; do
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
PROCESS_INFO=$(ps -p "$pid" -o pid,ppid,cmd --no-headers 2>/dev/null || echo "$pid (进程信息不可用)")
|
|
echo -e " ${GREEN}✓${NC} PID $PROCESS_INFO"
|
|
else
|
|
echo -e " ${RED}✗${NC} PID $pid (已停止)"
|
|
fi
|
|
done < "$PID_FILE"
|
|
else
|
|
echo -e "${YELLOW}未找到 PID 文件${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo ""
|
|
|
|
# 日志提示
|
|
if [ -d "$PROJECT_ROOT/logs" ]; then
|
|
echo -e "${YELLOW}💡 查看日志:${NC}"
|
|
echo -e " 后端: tail -f $PROJECT_ROOT/logs/backend.log"
|
|
echo -e " 前端: tail -f $PROJECT_ROOT/logs/frontend.log"
|
|
echo ""
|
|
fi |