feat: 项目初始化及当前全部内容提交

This commit is contained in:
2025-07-15 17:37:50 +08:00
parent ec817067f1
commit e78f192d34
622 changed files with 75174 additions and 383 deletions
+156
View File
@@ -0,0 +1,156 @@
#!/bin/bash
# 情绪博物馆微服务启动脚本
# 作者: emotion-museum
# 日期: 2025-07-12
echo "=========================================="
echo "情绪博物馆微服务启动脚本"
echo "=========================================="
# 检查Java环境
if ! command -v java &> /dev/null; then
echo "错误: 未找到Java环境,请安装JDK 17+"
exit 1
fi
# 检查Maven环境
if ! command -v mvn &> /dev/null; then
echo "错误: 未找到Maven环境,请安装Maven 3.6+"
exit 1
fi
# 检查Nacos是否运行
echo "检查Nacos服务状态..."
if ! curl -s http://localhost:8848/nacos/v1/ns/operator/metrics > /dev/null; then
echo "警告: Nacos服务未运行,请先启动Nacos"
echo "启动命令: sh nacos/bin/startup.sh -m standalone"
read -p "是否继续启动微服务? (y/n): " continue_start
if [[ $continue_start != "y" && $continue_start != "Y" ]]; then
exit 1
fi
fi
# 检查MySQL是否运行
echo "检查MySQL服务状态..."
if ! mysqladmin ping -h localhost --silent; then
echo "警告: MySQL服务未运行,请先启动MySQL"
read -p "是否继续启动微服务? (y/n): " continue_start
if [[ $continue_start != "y" && $continue_start != "Y" ]]; then
exit 1
fi
fi
# 检查Redis是否运行
echo "检查Redis服务状态..."
if ! redis-cli ping > /dev/null 2>&1; then
echo "警告: Redis服务未运行,请先启动Redis"
read -p "是否继续启动微服务? (y/n): " continue_start
if [[ $continue_start != "y" && $continue_start != "Y" ]]; then
exit 1
fi
fi
# 编译项目
echo "编译项目..."
mvn clean compile -DskipTests
if [ $? -ne 0 ]; then
echo "错误: 项目编译失败"
exit 1
fi
echo "编译成功!"
# 启动服务函数
start_service() {
local service_name=$1
local service_port=$2
echo "启动 $service_name 服务 (端口: $service_port)..."
cd $service_name
nohup mvn spring-boot:run > ../logs/${service_name}.log 2>&1 &
local pid=$!
echo $pid > ../logs/${service_name}.pid
cd ..
echo "$service_name 服务启动中... PID: $pid"
# 等待服务启动
local count=0
while [ $count -lt 30 ]; do
if curl -s http://localhost:$service_port/actuator/health > /dev/null 2>&1; then
echo "$service_name 服务启动成功!"
return 0
fi
sleep 2
count=$((count + 1))
echo -n "."
done
echo ""
echo "警告: $service_name 服务启动超时,请检查日志"
return 1
}
# 创建日志目录
mkdir -p logs
# 启动服务
echo "开始启动微服务..."
# 1. 启动网关服务
start_service "emotion-gateway" 9000
# 2. 启动用户服务
start_service "emotion-user" 9001
# 3. 启动AI对话服务
start_service "emotion-ai" 9002
# 4. 启动情绪记录服务
start_service "emotion-record" 9003
# 5. 启动成长课题服务
start_service "emotion-growth" 9004
# 6. 启动地图探索服务
start_service "emotion-explore" 9005
# 7. 启动成就奖励服务
start_service "emotion-reward" 9006
# 8. 启动统计分析服务
start_service "emotion-stats" 9007
echo ""
echo "=========================================="
echo "微服务启动完成!"
echo "=========================================="
echo "服务状态:"
echo "- 网关服务: http://localhost:9000"
echo "- 用户服务: http://localhost:9001"
echo "- AI对话服务: http://localhost:9002"
echo "- 情绪记录服务: http://localhost:9003"
echo "- 成长课题服务: http://localhost:9004"
echo "- 地图探索服务: http://localhost:9005"
echo "- 成就奖励服务: http://localhost:9006"
echo "- 统计分析服务: http://localhost:9007"
echo ""
echo "监控地址:"
echo "- 网关监控: http://localhost:9000/actuator/health"
echo "- 用户监控: http://localhost:9001/actuator/health"
echo "- AI对话监控: http://localhost:9002/actuator/health"
echo "- 情绪记录监控: http://localhost:9003/actuator/health"
echo "- 成长课题监控: http://localhost:9004/actuator/health"
echo "- 地图探索监控: http://localhost:9005/actuator/health"
echo "- 成就奖励监控: http://localhost:9006/actuator/health"
echo "- 统计分析监控: http://localhost:9007/actuator/health"
echo ""
echo "API文档地址:"
echo "- 网关API: http://localhost:9000/doc.html"
echo ""
echo "日志文件位置: ./logs/"
echo "停止服务命令: ./stop-services.sh"
echo "=========================================="