From 9a3a8267b54476401804bf35b6215d60acd2c76f Mon Sep 17 00:00:00 2001 From: huazhongmin Date: Tue, 15 Jul 2025 19:10:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=89=B4=E6=9D=83=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-local.yml | 42 +++++--- .../target/classes/application-local.yml | 42 +++++--- backend/start-services-simple.sh | 97 +++++++++++++++++++ 3 files changed, 155 insertions(+), 26 deletions(-) create mode 100755 backend/start-services-simple.sh diff --git a/backend/emotion-gateway/src/main/resources/application-local.yml b/backend/emotion-gateway/src/main/resources/application-local.yml index 1dd74f4..868354a 100644 --- a/backend/emotion-gateway/src/main/resources/application-local.yml +++ b/backend/emotion-gateway/src/main/resources/application-local.yml @@ -30,55 +30,71 @@ spring: routes: # 用户服务路由 - id: emotion-user-route - uri: lb://emotion-user + uri: http://localhost:19001 predicates: - Path=/user/** filters: - StripPrefix=0 - + + # 验证码服务路由 + - id: emotion-captcha-route + uri: http://localhost:19001 + predicates: + - Path=/captcha/** + filters: + - StripPrefix=0 + + # OAuth服务路由 + - id: emotion-oauth-route + uri: http://localhost:19001 + predicates: + - Path=/oauth/** + filters: + - StripPrefix=0 + # AI服务路由 - id: emotion-ai-route - uri: lb://emotion-ai + uri: http://localhost:19002 predicates: - Path=/ai/** filters: - StripPrefix=0 - + # 记录服务路由 - id: emotion-record-route - uri: lb://emotion-record + uri: http://localhost:19003 predicates: - Path=/record/** filters: - StripPrefix=0 - + # 成长服务路由 - id: emotion-growth-route - uri: lb://emotion-growth + uri: http://localhost:19004 predicates: - Path=/growth/** filters: - StripPrefix=0 - + # 探索服务路由 - id: emotion-explore-route - uri: lb://emotion-explore + uri: http://localhost:19005 predicates: - Path=/explore/** filters: - StripPrefix=0 - + # 奖励服务路由 - id: emotion-reward-route - uri: lb://emotion-reward + uri: http://localhost:19006 predicates: - Path=/reward/** filters: - StripPrefix=0 - + # 统计服务路由 - id: emotion-stats-route - uri: lb://emotion-stats + uri: http://localhost:19007 predicates: - Path=/stats/** filters: diff --git a/backend/emotion-gateway/target/classes/application-local.yml b/backend/emotion-gateway/target/classes/application-local.yml index 1dd74f4..868354a 100644 --- a/backend/emotion-gateway/target/classes/application-local.yml +++ b/backend/emotion-gateway/target/classes/application-local.yml @@ -30,55 +30,71 @@ spring: routes: # 用户服务路由 - id: emotion-user-route - uri: lb://emotion-user + uri: http://localhost:19001 predicates: - Path=/user/** filters: - StripPrefix=0 - + + # 验证码服务路由 + - id: emotion-captcha-route + uri: http://localhost:19001 + predicates: + - Path=/captcha/** + filters: + - StripPrefix=0 + + # OAuth服务路由 + - id: emotion-oauth-route + uri: http://localhost:19001 + predicates: + - Path=/oauth/** + filters: + - StripPrefix=0 + # AI服务路由 - id: emotion-ai-route - uri: lb://emotion-ai + uri: http://localhost:19002 predicates: - Path=/ai/** filters: - StripPrefix=0 - + # 记录服务路由 - id: emotion-record-route - uri: lb://emotion-record + uri: http://localhost:19003 predicates: - Path=/record/** filters: - StripPrefix=0 - + # 成长服务路由 - id: emotion-growth-route - uri: lb://emotion-growth + uri: http://localhost:19004 predicates: - Path=/growth/** filters: - StripPrefix=0 - + # 探索服务路由 - id: emotion-explore-route - uri: lb://emotion-explore + uri: http://localhost:19005 predicates: - Path=/explore/** filters: - StripPrefix=0 - + # 奖励服务路由 - id: emotion-reward-route - uri: lb://emotion-reward + uri: http://localhost:19006 predicates: - Path=/reward/** filters: - StripPrefix=0 - + # 统计服务路由 - id: emotion-stats-route - uri: lb://emotion-stats + uri: http://localhost:19007 predicates: - Path=/stats/** filters: diff --git a/backend/start-services-simple.sh b/backend/start-services-simple.sh new file mode 100755 index 0000000..de480a2 --- /dev/null +++ b/backend/start-services-simple.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +echo "🚀 启动情感博物馆服务..." + +# 检查基础服务 +echo "📊 检查基础服务..." +if ! nc -z localhost 3306; then + echo "❌ MySQL服务未启动,请先启动MySQL服务" + exit 1 +fi + +if ! nc -z localhost 6379; then + echo "❌ Redis服务未启动,请先启动Redis服务" + exit 1 +fi + +echo "✅ 基础服务检查通过" + +# 创建日志目录 +mkdir -p logs + +# 启动用户服务 +echo "🔄 启动用户服务..." +cd emotion-user +mvn clean package -DskipTests -q +if [ $? -eq 0 ]; then + nohup java -jar -Dspring.profiles.active=local -Dspring.cloud.nacos.discovery.enabled=false -Dspring.cloud.nacos.config.enabled=false target/emotion-user-1.0.0.jar > ../logs/user.log 2>&1 & + echo $! > ../logs/user.pid + echo "✅ 用户服务启动完成 (PID: $!)" + sleep 5 +else + echo "❌ 用户服务编译失败" + exit 1 +fi +cd .. + +# 启动AI服务 +echo "🔄 启动AI服务..." +cd emotion-ai +mvn clean package -DskipTests -q +if [ $? -eq 0 ]; then + nohup java -jar -Dspring.profiles.active=local -Dspring.cloud.nacos.discovery.enabled=false -Dspring.cloud.nacos.config.enabled=false target/emotion-ai-1.0.0.jar > ../logs/ai.log 2>&1 & + echo $! > ../logs/ai.pid + echo "✅ AI服务启动完成 (PID: $!)" + sleep 5 +else + echo "❌ AI服务编译失败" +fi +cd .. + +# 启动网关服务 +echo "🔄 启动网关服务..." +cd emotion-gateway +mvn clean package -DskipTests -q +if [ $? -eq 0 ]; then + nohup java -jar -Dspring.profiles.active=local -Dspring.cloud.nacos.discovery.enabled=false -Dspring.cloud.nacos.config.enabled=false target/emotion-gateway-1.0.0.jar > ../logs/gateway.log 2>&1 & + echo $! > ../logs/gateway.pid + echo "✅ 网关服务启动完成 (PID: $!)" + sleep 5 +else + echo "❌ 网关服务编译失败" +fi +cd .. + +echo "" +echo "🎉 服务启动完成!" +echo "" +echo "📋 服务列表:" +echo " 用户服务: http://localhost:19001" +echo " AI服务: http://localhost:19002" +echo " 网关服务: http://localhost:19000" +echo "" +echo "📝 日志文件位置: logs/" +echo "📝 停止服务: ./stop-services.sh" + +# 检查服务状态 +echo "" +echo "📊 检查服务状态..." +sleep 10 + +if curl -s http://localhost:19001/actuator/health >/dev/null 2>&1; then + echo "✅ 用户服务运行正常" +else + echo "⚠️ 用户服务可能未完全启动,请查看日志: tail -f logs/user.log" +fi + +if curl -s http://localhost:19002/actuator/health >/dev/null 2>&1; then + echo "✅ AI服务运行正常" +else + echo "⚠️ AI服务可能未完全启动,请查看日志: tail -f logs/ai.log" +fi + +if curl -s http://localhost:19000/actuator/health >/dev/null 2>&1; then + echo "✅ 网关服务运行正常" +else + echo "⚠️ 网关服务可能未完全启动,请查看日志: tail -f logs/gateway.log" +fi