bug修复

This commit is contained in:
2025-10-26 23:26:30 +08:00
parent 85e910fac9
commit df818578e5
20 changed files with 2008 additions and 98 deletions
Executable
+188
View File
@@ -0,0 +1,188 @@
#!/bin/bash
# 情绪博物馆 - 一键式部署脚本
# 同时部署后端和前端到远程服务器 101.200.208.45
# 使用方法: bash deploy-all.sh [backend|frontend|all]
# 默认部署所有服务
set -e
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# 日志函数
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
log_section() {
echo ""
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}${NC} $1"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
}
# 获取脚本所在目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# 部署类型(默认为all
DEPLOY_TYPE="${1:-all}"
# 验证部署类型
if [[ ! "$DEPLOY_TYPE" =~ ^(backend|frontend|all)$ ]]; then
log_error "无效的部署类型: $DEPLOY_TYPE"
echo "使用方法: bash deploy-all.sh [backend|frontend|all]"
exit 1
fi
# 记录开始时间
START_TIME=$(date +%s)
# ============================================================================
# 部署后端
# ============================================================================
deploy_backend() {
log_section "开始部署后端服务"
if [ ! -f "backend-single/deploy.sh" ]; then
log_error "后端部署脚本不存在: backend-single/deploy.sh"
return 1
fi
log_info "执行后端部署脚本..."
cd backend-single
if bash deploy.sh remote; then
log_info "✅ 后端部署成功"
cd ..
return 0
else
log_error "❌ 后端部署失败"
cd ..
return 1
fi
}
# ============================================================================
# 部署前端
# ============================================================================
deploy_frontend() {
log_section "开始部署前端应用"
if [ ! -f "web/deploy.sh" ]; then
log_error "前端部署脚本不存在: web/deploy.sh"
return 1
fi
log_info "执行前端部署脚本..."
cd web
if bash deploy.sh; then
log_info "✅ 前端部署成功"
cd ..
return 0
else
log_error "❌ 前端部署失败"
cd ..
return 1
fi
}
# ============================================================================
# 主程序
# ============================================================================
log_section "情绪博物馆 - 一键式部署"
log_info "部署类型: $DEPLOY_TYPE"
log_info "部署时间: $(date '+%Y-%m-%d %H:%M:%S')"
BACKEND_SUCCESS=true
FRONTEND_SUCCESS=true
# 执行部署
case "$DEPLOY_TYPE" in
backend)
if ! deploy_backend; then
BACKEND_SUCCESS=false
fi
;;
frontend)
if ! deploy_frontend; then
FRONTEND_SUCCESS=false
fi
;;
all)
if ! deploy_backend; then
BACKEND_SUCCESS=false
fi
if ! deploy_frontend; then
FRONTEND_SUCCESS=false
fi
;;
esac
# ============================================================================
# 部署总结
# ============================================================================
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
log_section "部署完成总结"
if [ "$DEPLOY_TYPE" = "backend" ] || [ "$DEPLOY_TYPE" = "all" ]; then
if [ "$BACKEND_SUCCESS" = true ]; then
log_info "✅ 后端部署: 成功"
else
log_error "❌ 后端部署: 失败"
fi
fi
if [ "$DEPLOY_TYPE" = "frontend" ] || [ "$DEPLOY_TYPE" = "all" ]; then
if [ "$FRONTEND_SUCCESS" = true ]; then
log_info "✅ 前端部署: 成功"
else
log_error "❌ 前端部署: 失败"
fi
fi
log_info "部署耗时: ${DURATION}"
# ============================================================================
# 访问信息
# ============================================================================
if [ "$BACKEND_SUCCESS" = true ] && [ "$FRONTEND_SUCCESS" = true ]; then
echo ""
log_section "部署成功!"
log_info "📱 前端访问地址: http://101.200.208.45/emotion-museum/"
log_info "🔌 后端API地址: http://101.200.208.45:19089/api"
log_info "📊 WebSocket地址: ws://101.200.208.45:19089/ws"
echo ""
exit 0
elif [ "$BACKEND_SUCCESS" = true ]; then
log_warn "⚠️ 后端部署成功,前端部署失败"
exit 1
elif [ "$FRONTEND_SUCCESS" = true ]; then
log_warn "⚠️ 前端部署成功,后端部署失败"
exit 1
else
log_error "❌ 部署失败"
exit 1
fi