feat: 添加生产环境部署和监控配置

- 新增生产环境部署脚本和文档
- 添加监控系统配置(Alertmanager, Prometheus, Grafana)
- 更新e2e测试用例以适配新环境
- 添加.env.production配置文件
- 优化Sentry初始化逻辑为动态加载
- 新增全局设置脚本以支持不同环境
This commit is contained in:
张翔
2026-03-09 16:37:23 +08:00
parent 261c45b4d9
commit 4ece85a9c3
14 changed files with 950 additions and 356 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
set -e
echo "🚀 开始部署到生产环境..."
# 加载生产环境变量
export NODE_ENV=production
# 检查是否已安装依赖
if [ ! -d "node_modules" ]; then
echo "📦 安装依赖..."
npm ci --production=false
fi
# 运行测试
echo "🧪 运行测试..."
cd e2e
TEST_ENV=development npx playwright test --reporter=list
cd ..
# 构建生产版本
echo "🔨 构建生产版本..."
npm run build
# 备份当前版本(如果存在)
if [ -d "dist_backup" ]; then
rm -rf dist_backup
fi
if [ -d "dist" ]; then
echo "💾 备份当前版本..."
mv dist dist_backup
fi
# 启动生产服务器
echo "🌟 启动生产服务器..."
npm start &
# 等待服务器启动
echo "⏳ 等待服务器启动..."
sleep 10
# 健康检查
echo "🏥 健康检查..."
curl -f http://localhost:3000/api/health || {
echo "❌ 健康检查失败!"
exit 1
}
echo "✅ 部署成功!"
echo "📊 访问 http://localhost:3000"