feat: Complete production deployment pipeline with admin dashboard
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

- Add unified deployment script with Node.js 22 installation
- Create comprehensive database migration script (28 migrations + admin tables)
- Add production start/stop scripts for all services
- Integrate admin dashboard (parentflow-admin) into PM2 ecosystem
- Configure all services: Backend (3020), Frontend (3030), Admin (3335)
- Update ecosystem.config.js with admin dashboard configuration
- Add invite codes module for user registration management
This commit is contained in:
2025-10-06 22:43:28 +00:00
parent 560fd22023
commit 4e19b992df
37 changed files with 6767 additions and 675 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# ParentFlow Production Stop Script
# Stops PM2 processes and Docker containers gracefully
# Stops all production services gracefully
set -e
@@ -10,68 +10,138 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
CYAN='\033[0;36m'
NC='\033[0m'
log() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1" >&2
}
success() {
echo -e "${GREEN}${NC} $1"
}
warning() {
echo -e "${YELLOW}${NC} $1"
}
# Header
echo ""
echo "=========================================="
echo "Stopping ParentFlow Production"
echo " Stopping ParentFlow Production "
echo "=========================================="
echo ""
# Step 1: Stop PM2 processes
echo -e "${BLUE}Step 1: Stopping PM2 processes...${NC}"
log "${CYAN}Step 1: Stopping PM2 services...${NC}"
if command -v pm2 &> /dev/null; then
pm2 stop all 2>/dev/null || true
echo -e "${GREEN}✓ PM2 processes stopped${NC}"
# Show current status
echo "Current PM2 processes:"
pm2 list
# Stop all PM2 processes
pm2 stop all 2>/dev/null || warning "No PM2 processes were running"
# Delete all PM2 processes
pm2 delete all 2>/dev/null || warning "No PM2 processes to delete"
# Kill PM2 daemon
pm2 kill
success "PM2 services stopped"
else
echo -e "${YELLOW}Warning: PM2 not found${NC}"
warning "PM2 not found"
fi
# Step 2: Stop Docker containers
echo ""
echo -e "${BLUE}Step 2: Stopping Docker containers...${NC}"
if docker compose version &> /dev/null; then
docker compose -f docker-compose.production.yml down
else
docker-compose -f docker-compose.production.yml down 2>/dev/null || true
fi
# Step 2: Stop Docker services
log "${CYAN}Step 2: Stopping Docker services...${NC}"
DEPLOY_DIR="/root/parentflow-production"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Docker containers stopped${NC}"
else
echo -e "${YELLOW}Warning: Failed to stop some Docker containers${NC}"
fi
# Verify everything is stopped
echo ""
echo -e "${BLUE}Verification:${NC}"
# Check PM2
if command -v pm2 &> /dev/null; then
RUNNING_PROCESSES=$(pm2 jlist 2>/dev/null | jq -r '.[] | select(.pm2_env.status == "online") | .name' | wc -l)
if [ "$RUNNING_PROCESSES" -eq 0 ]; then
echo -e "${GREEN}✓ No PM2 processes running${NC}"
# Try to find docker-compose file
if [ -f "$DEPLOY_DIR/docker-compose.production.yml" ]; then
cd "$DEPLOY_DIR"
if docker compose version &> /dev/null; then
docker compose -f docker-compose.production.yml down
else
echo -e "${YELLOW}Warning: $RUNNING_PROCESSES PM2 processes still running${NC}"
docker-compose -f docker-compose.production.yml down
fi
fi
# Check Docker
RUNNING_CONTAINERS=$(docker ps --filter name=parentflow --format "{{.Names}}" | wc -l)
if [ "$RUNNING_CONTAINERS" -eq 0 ]; then
echo -e "${GREEN}✓ No ParentFlow Docker containers running${NC}"
success "Docker services stopped"
elif [ -f "./docker-compose.production.yml" ]; then
if docker compose version &> /dev/null; then
docker compose -f docker-compose.production.yml down
else
docker-compose -f docker-compose.production.yml down
fi
success "Docker services stopped"
else
echo -e "${YELLOW}Warning: $RUNNING_CONTAINERS containers still running${NC}"
docker ps --filter name=parentflow
warning "Docker compose file not found, skipping..."
fi
# Step 3: Kill any remaining Node processes on production ports
log "${CYAN}Step 3: Cleaning up remaining processes...${NC}"
kill_port() {
local port=$1
local name=$2
if lsof -i:$port > /dev/null 2>&1; then
log "Stopping $name on port $port..."
lsof -ti:$port | xargs -r kill -9
success "$name stopped"
else
echo " $name not running on port $port"
fi
}
kill_port 3020 "Backend API"
kill_port 3030 "Frontend"
kill_port 3335 "Admin Dashboard"
# Step 4: Clean up temporary files
log "${CYAN}Step 4: Cleaning up temporary files...${NC}"
rm -rf /tmp/pm2-* 2>/dev/null || true
rm -rf /tmp/next-* 2>/dev/null || true
success "Temporary files cleaned"
# Step 5: Verify all services are stopped
log "${CYAN}Step 5: Verifying all services are stopped...${NC}"
check_port() {
local port=$1
local name=$2
if lsof -i:$port > /dev/null 2>&1; then
warning "$name still running on port $port"
return 1
else
success "$name stopped (port $port free)"
return 0
fi
}
ALL_STOPPED=true
check_port 3020 "Backend API" || ALL_STOPPED=false
check_port 3030 "Frontend" || ALL_STOPPED=false
check_port 3335 "Admin Dashboard" || ALL_STOPPED=false
check_port 6379 "Redis" || true # Redis might be used by other services
check_port 27017 "MongoDB" || true # MongoDB might be used by other services
check_port 9000 "MinIO" || true # MinIO might be used by other services
# Final summary
echo ""
echo "=========================================="
echo -e "${GREEN}Production environment stopped${NC}"
if [ "$ALL_STOPPED" = true ]; then
echo -e "${GREEN} All Services Stopped Successfully! ${NC}"
else
echo -e "${YELLOW} Services Stopped (Check Warnings) ${NC}"
fi
echo "=========================================="
echo ""
echo "To completely remove Docker volumes (WARNING: deletes data):"
echo " docker-compose -f docker-compose.production.yml down -v"
echo "To restart services, run:"
echo " ./start-production.sh"
echo ""
echo "To remove PM2 processes from startup:"
echo " pm2 delete all"
echo " pm2 save"
log "Services stopped at $(date)"