Files
你的用户名 237c7802e5
Some checks failed
Deploy / deploy (push) Has been cancelled
Initial commit: Telegram Management System
Full-stack web application for Telegram management
- Frontend: Vue 3 + Vben Admin
- Backend: NestJS
- Features: User management, group broadcast, statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 15:37:50 +08:00

71 lines
1.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Telegram管理系统启动脚本
set -e
echo "🚀 启动 Telegram 管理系统..."
# 检查环境
if [ "$NODE_ENV" = "production" ]; then
echo "📦 生产环境启动"
ENV_FILE=".env.production"
else
echo "🔧 开发环境启动"
ENV_FILE=".env"
fi
# 检查环境变量文件
if [ ! -f "$ENV_FILE" ]; then
echo "❌ 环境变量文件 $ENV_FILE 不存在"
exit 1
fi
# 加载环境变量
export $(cat $ENV_FILE | grep -v '^#' | xargs)
# 检查依赖服务
echo "🔍 检查依赖服务..."
# 检查MySQL
echo "检查MySQL连接..."
if ! timeout 30 bash -c "until mysqladmin ping -h${DB_HOST:-localhost} -P${DB_PORT:-3306} -u${DB_USERNAME} -p${DB_PASSWORD} --silent; do sleep 1; done"; then
echo "❌ MySQL连接失败"
exit 1
fi
echo "✅ MySQL连接成功"
# 检查Redis
echo "检查Redis连接..."
if ! timeout 30 bash -c "until redis-cli -h ${REDIS_HOST:-localhost} -p ${REDIS_PORT:-6379} ping; do sleep 1; done"; then
echo "❌ Redis连接失败"
exit 1
fi
echo "✅ Redis连接成功"
# 检查RabbitMQ
echo "检查RabbitMQ连接..."
if ! timeout 30 bash -c "until curl -f http://${RABBITMQ_HOST:-localhost}:15672/api/overview > /dev/null 2>&1; do sleep 1; done"; then
echo "⚠️ RabbitMQ管理界面检查失败但继续启动"
fi
# 运行数据库迁移
echo "🗄️ 运行数据库迁移..."
if [ -f "dist/database/migrations" ]; then
node dist/database/migrations/run-migrations.js || echo "⚠️ 数据库迁移失败,但继续启动"
fi
# 创建必要的目录
echo "📁 创建必要的目录..."
mkdir -p logs uploads scripts
# 设置权限
chmod 755 logs uploads scripts
# 启动应用
echo "🎯 启动应用服务..."
if [ "$NODE_ENV" = "production" ]; then
exec node dist/main.js
else
exec npm run start:dev
fi