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

144 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# Startup script for Telegram Marketing Agent System
# This script starts all services in the correct order
echo "🚀 Starting Telegram Marketing Agent System..."
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to check if service is running
check_service() {
local service_name=$1
local port=$2
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null ; then
echo -e "${GREEN}$service_name is running on port $port${NC}"
return 0
else
echo -e "${RED}$service_name is not running on port $port${NC}"
return 1
fi
}
# Function to wait for service
wait_for_service() {
local service_name=$1
local port=$2
local max_attempts=30
local attempt=0
echo -e "${YELLOW}Waiting for $service_name to start...${NC}"
while [ $attempt -lt $max_attempts ]; do
if check_service "$service_name" "$port"; then
return 0
fi
sleep 2
attempt=$((attempt + 1))
done
echo -e "${RED}Failed to start $service_name${NC}"
return 1
}
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo -e "${RED}Docker is not running. Please start Docker first.${NC}"
exit 1
fi
# Start infrastructure services first
echo -e "\n${YELLOW}Starting infrastructure services...${NC}"
docker-compose up -d mongodb redis postgres rabbitmq elasticsearch
# Wait for infrastructure services
wait_for_service "MongoDB" 27017
wait_for_service "Redis" 6379
wait_for_service "PostgreSQL" 5432
wait_for_service "RabbitMQ" 5672
wait_for_service "Elasticsearch" 9200
# Start core services
echo -e "\n${YELLOW}Starting core services...${NC}"
docker-compose up -d orchestrator gramjs-adapter safety-guard compliance-guard
# Wait for core services
wait_for_service "Orchestrator" 3001
wait_for_service "GramJS Adapter" 3003
wait_for_service "Safety Guard" 3004
wait_for_service "Compliance Guard" 3006
# Start analytics and AI services
echo -e "\n${YELLOW}Starting analytics and AI services...${NC}"
docker-compose up -d analytics ab-testing claude-agent
# Wait for analytics and AI services
wait_for_service "Analytics" 3005
wait_for_service "A/B Testing" 3007
wait_for_service "Claude Agent" 3002
# Start API Gateway
echo -e "\n${YELLOW}Starting API Gateway...${NC}"
docker-compose up -d api-gateway
# Wait for API Gateway
wait_for_service "API Gateway" 3030
# Start Frontend
echo -e "\n${YELLOW}Starting Frontend...${NC}"
docker-compose up -d frontend
# Wait for Frontend
wait_for_service "Frontend" 3008
# Check overall system status
echo -e "\n${YELLOW}Checking system status...${NC}"
all_services_running=true
# Check all services
services=(
"MongoDB:27017"
"Redis:6379"
"PostgreSQL:5432"
"RabbitMQ:5672"
"Elasticsearch:9200"
"API Gateway:3030"
"Orchestrator:3001"
"Claude Agent:3002"
"GramJS Adapter:3003"
"Safety Guard:3004"
"Analytics:3005"
"Compliance Guard:3006"
"A/B Testing:3007"
"Frontend:3008"
)
for service in "${services[@]}"; do
IFS=':' read -r name port <<< "$service"
if ! check_service "$name" "$port"; then
all_services_running=false
fi
done
if [ "$all_services_running" = true ]; then
echo -e "\n${GREEN}✨ All services are running successfully!${NC}"
echo -e "\n${GREEN}Access the application at: http://localhost:3008${NC}"
echo -e "${GREEN}API Gateway available at: http://localhost:3030${NC}"
echo -e "${GREEN}API Documentation at: http://localhost:3030/api-docs${NC}"
else
echo -e "\n${RED}Some services failed to start. Check the logs with:${NC}"
echo "docker-compose logs [service-name]"
fi
echo -e "\n${YELLOW}Useful commands:${NC}"
echo "- View all logs: docker-compose logs -f"
echo "- View specific service logs: docker-compose logs -f [service-name]"
echo "- Stop all services: docker-compose down"
echo "- Restart a service: docker-compose restart [service-name]"
echo "- View service status: docker-compose ps"