AudioForge / scripts /demo_launch.ps1
OnyxlMunkey's picture
c618549
# ============================================
# AudioForge - Professional Demo Launch
# ============================================
# Uses alternative ports to avoid conflicts
# Perfect for live presentations
param(
[switch]$Build
)
# Colors
$ESC = [char]27
$GREEN = "$ESC[32m"
$BLUE = "$ESC[34m"
$YELLOW = "$ESC[33m"
$RED = "$ESC[31m"
$CYAN = "$ESC[36m"
$MAGENTA = "$ESC[35m"
$RESET = "$ESC[0m"
$BOLD = "$ESC[1m"
# Banner
function Show-Banner {
Clear-Host
Write-Host ""
Write-Host "${CYAN}${BOLD}╔═══════════════════════════════════════════════════════════════╗${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ ${MAGENTA}🎡 AUDIOFORGE 🎡${CYAN} β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ ${RESET}Open-Source Text-to-Music Generation Platform${CYAN} β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ ${GREEN}πŸš€ LIVE DEMONSTRATION MODE πŸš€${CYAN} β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•‘ β•‘${RESET}"
Write-Host "${CYAN}${BOLD}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${RESET}"
Write-Host ""
}
function Write-Status { param([string]$Message) Write-Host "${BLUE}[INFO]${RESET} $Message" }
function Write-Success { param([string]$Message) Write-Host "${GREEN}[βœ“]${RESET} $Message" }
function Write-Warning { param([string]$Message) Write-Host "${YELLOW}[!]${RESET} $Message" }
function Write-Error-Custom { param([string]$Message) Write-Host "${RED}[βœ—]${RESET} $Message" }
function Write-Section { param([string]$Title) Write-Host ""; Write-Host "${BOLD}${CYAN}═══ $Title ═══${RESET}"; Write-Host "" }
Show-Banner
Write-Section "System Check"
# Check Docker
try {
$dockerVersion = docker --version
Write-Success "Docker: $dockerVersion"
} catch {
Write-Error-Custom "Docker not found"
exit 1
}
# Check if Docker is running
try {
docker ps | Out-Null
Write-Success "Docker daemon is running"
} catch {
Write-Error-Custom "Docker daemon is not running"
exit 1
}
Write-Section "Port Configuration"
Write-Status "Using alternative ports to avoid conflicts:"
Write-Host " ${CYAN}Frontend:${RESET} http://localhost:3000"
Write-Host " ${CYAN}Backend:${RESET} http://localhost:8001 ${YELLOW}(Note: Port 8001)${RESET}"
Write-Host " ${CYAN}PostgreSQL:${RESET} localhost:5433"
Write-Host " ${CYAN}Redis:${RESET} localhost:6380"
Write-Host ""
if ($Build) {
Write-Section "Building Docker Images"
Write-Status "This may take 5-10 minutes on first run..."
docker-compose -f docker-compose.demo.yml build --no-cache
if ($LASTEXITCODE -eq 0) {
Write-Success "Build completed successfully"
} else {
Write-Error-Custom "Build failed"
exit 1
}
}
Write-Section "Starting Services"
Write-Status "Starting database services..."
docker-compose -f docker-compose.demo.yml up -d postgres redis
Start-Sleep -Seconds 8
Write-Status "Starting backend API..."
docker-compose -f docker-compose.demo.yml up -d backend
Start-Sleep -Seconds 15
Write-Status "Starting frontend..."
docker-compose -f docker-compose.demo.yml up -d frontend
Start-Sleep -Seconds 10
Write-Section "Health Check"
$maxRetries = 20
$retryCount = 0
Write-Status "Checking PostgreSQL..."
while ($retryCount -lt $maxRetries) {
$health = docker inspect --format='{{.State.Health.Status}}' audioforge-postgres 2>$null
if ($health -eq "healthy") {
Write-Success "PostgreSQL is healthy"
break
}
Start-Sleep -Seconds 2
$retryCount++
}
Write-Status "Checking Redis..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
$health = docker inspect --format='{{.State.Health.Status}}' audioforge-redis 2>$null
if ($health -eq "healthy") {
Write-Success "Redis is healthy"
break
}
Start-Sleep -Seconds 2
$retryCount++
}
Write-Status "Checking Backend API..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:8001/health" -UseBasicParsing -TimeoutSec 2 -ErrorAction SilentlyContinue
if ($response.StatusCode -eq 200) {
Write-Success "Backend API is healthy"
break
}
} catch { }
Start-Sleep -Seconds 3
$retryCount++
}
Write-Status "Checking Frontend..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:3000" -UseBasicParsing -TimeoutSec 2 -ErrorAction SilentlyContinue
if ($response.StatusCode -eq 200) {
Write-Success "Frontend is healthy"
break
}
} catch { }
Start-Sleep -Seconds 3
$retryCount++
}
Write-Section "Service Status"
docker-compose -f docker-compose.demo.yml ps
Write-Host ""
Write-Host "${BOLD}Container Resource Usage:${RESET}"
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" audioforge-postgres audioforge-redis audioforge-backend audioforge-frontend 2>$null
Write-Section "Access Information"
Write-Host "${BOLD}${GREEN}🌐 Application URLs:${RESET}"
Write-Host ""
Write-Host " ${BOLD}${CYAN}Frontend:${RESET} ${GREEN}http://localhost:3000${RESET}"
Write-Host " ${BOLD}${CYAN}Backend API:${RESET} ${GREEN}http://localhost:8001${RESET}"
Write-Host " ${BOLD}${CYAN}API Docs:${RESET} ${GREEN}http://localhost:8001/docs${RESET}"
Write-Host " ${BOLD}${CYAN}API Redoc:${RESET} ${GREEN}http://localhost:8001/redoc${RESET}"
Write-Host " ${BOLD}${CYAN}Health Check:${RESET} ${GREEN}http://localhost:8001/health${RESET}"
Write-Host ""
Write-Host "${BOLD}${MAGENTA}πŸ“Š Technical Specifications:${RESET}"
Write-Host ""
Write-Host " ${CYAN}Architecture:${RESET} Microservices with Docker"
Write-Host " ${CYAN}Backend:${RESET} FastAPI + Python 3.11"
Write-Host " ${CYAN}Frontend:${RESET} Next.js 14 + TypeScript"
Write-Host " ${CYAN}Database:${RESET} PostgreSQL 16"
Write-Host " ${CYAN}Cache:${RESET} Redis 7"
Write-Host " ${CYAN}ML Models:${RESET} MusicGen + Bark"
Write-Host ""
Write-Section "Recent Logs"
Write-Host "${CYAN}Backend (last 5 lines):${RESET}"
docker-compose -f docker-compose.demo.yml logs --tail=5 backend 2>$null
Write-Host ""
Write-Host "${CYAN}Frontend (last 5 lines):${RESET}"
docker-compose -f docker-compose.demo.yml logs --tail=5 frontend 2>$null
Write-Host ""
Write-Host "${BOLD}${GREEN}╔═══════════════════════════════════════════════════════════════╗${RESET}"
Write-Host "${BOLD}${GREEN}β•‘ β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘ πŸŽ‰ AUDIOFORGE IS READY FOR DEMO! πŸŽ‰ β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘ β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘ Visit ${CYAN}http://localhost:3000${GREEN} to begin β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘ β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${RESET}"
Write-Host ""
Write-Host "${YELLOW}πŸ“ Quick Commands:${RESET}"
Write-Host " ${CYAN}View logs:${RESET} docker-compose -f docker-compose.demo.yml logs -f"
Write-Host " ${CYAN}Stop services:${RESET} docker-compose -f docker-compose.demo.yml down"
Write-Host " ${CYAN}Restart:${RESET} docker-compose -f docker-compose.demo.yml restart"
Write-Host ""
Write-Host "${YELLOW}🎯 Demo Tips:${RESET}"
Write-Host " 1. Open ${CYAN}http://localhost:3000${RESET} for the UI"
Write-Host " 2. Try prompt: ${GREEN}'Upbeat electronic dance music'${RESET}"
Write-Host " 3. Show API docs at ${CYAN}http://localhost:8001/docs${RESET}"
Write-Host " 4. Monitor logs in real-time"
Write-Host ""