File size: 5,852 Bytes
da2713e 104d504 da2713e 104d504 da2713e 104d504 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | # Fresh Start Script for Graph-Driven Agentic System (Windows PowerShell)
# Run this script to deploy the system from scratch
param(
[string]$ApiKey = "",
[string]$Model = "gpt-4"
)
Write-Host "π Fresh Start Deployment" -ForegroundColor Green
Write-Host "=========================" -ForegroundColor Green
Write-Host ""
# Step 1: Check prerequisites
Write-Host "π Step 1: Checking prerequisites..." -ForegroundColor Blue
try {
docker --version | Out-Null
Write-Host "β
Docker found" -ForegroundColor Green
} catch {
Write-Host "β Docker not found. Please install Docker Desktop" -ForegroundColor Red
exit 1
}
try {
docker-compose --version | Out-Null
Write-Host "β
Docker Compose found" -ForegroundColor Green
} catch {
Write-Host "β Docker Compose not found" -ForegroundColor Red
exit 1
}
# Step 2: Setup environment
Write-Host ""
Write-Host "βοΈ Step 2: Setting up environment..." -ForegroundColor Blue
if (Test-Path ".env") {
Write-Host "β οΈ .env file already exists, backing up to .env.backup" -ForegroundColor Yellow
Copy-Item ".env" ".env.backup"
}
Copy-Item ".env.example" ".env"
Write-Host "β
Created .env from template" -ForegroundColor Green
# Update API key if provided
if ($ApiKey -ne "") {
(Get-Content ".env") -replace "LLM_API_KEY=.*", "LLM_API_KEY=$ApiKey" | Set-Content ".env"
(Get-Content ".env") -replace "LLM_MODEL=.*", "LLM_MODEL=$Model" | Set-Content ".env"
Write-Host "β
Updated LLM configuration in .env" -ForegroundColor Green
} else {
Write-Host "β οΈ No API key provided. You will need to edit .env manually" -ForegroundColor Yellow
Write-Host " Add your OpenAI or Anthropic API key to the LLM_API_KEY variable" -ForegroundColor Gray
}
# Step 3: Clean existing containers
Write-Host ""
Write-Host "π§Ή Step 3: Cleaning existing containers..." -ForegroundColor Blue
docker-compose down 2>$null
docker system prune -f 2>$null
Write-Host "β
Cleaned existing containers" -ForegroundColor Green
# Step 4: Build services
Write-Host ""
Write-Host "π¨ Step 4: Building services..." -ForegroundColor Blue
docker-compose build
if ($LASTEXITCODE -ne 0) {
Write-Host "β Build failed" -ForegroundColor Red
exit 1
}
Write-Host "β
All services built successfully" -ForegroundColor Green
# Step 5: Start services
Write-Host ""
Write-Host "π Step 5: Starting services..." -ForegroundColor Blue
docker-compose up -d
if ($LASTEXITCODE -ne 0) {
Write-Host "β Failed to start services" -ForegroundColor Red
exit 1
}
Write-Host "β
All services started" -ForegroundColor Green
# Step 6: Wait for health checks
Write-Host ""
Write-Host "β³ Step 6: Waiting for services to be healthy (60 seconds)..." -ForegroundColor Blue
$healthyServices = 0
$maxWait = 60
$elapsed = 0
while ($elapsed -lt $maxWait -and $healthyServices -lt 3) {
Start-Sleep 5
$elapsed += 5
$healthyServices = 0
# Check Neo4j
try {
docker-compose exec neo4j cypher-shell -u neo4j -p password "MATCH (n) RETURN count(n) LIMIT 1" 2>$null | Out-Null
if ($LASTEXITCODE -eq 0) { $healthyServices++ }
} catch {}
# Check PostgreSQL
try {
docker-compose exec postgres pg_isready -U postgres 2>$null | Out-Null
if ($LASTEXITCODE -eq 0) { $healthyServices++ }
} catch {}
# Check MCP
try {
$response = Invoke-WebRequest -Uri "http://localhost:8000/health" -UseBasicParsing -TimeoutSec 2 2>$null
if ($response.StatusCode -eq 200) { $healthyServices++ }
} catch {}
Write-Host " Healthy services: $healthyServices/3 (${elapsed}s elapsed)" -ForegroundColor Gray
}
if ($healthyServices -eq 3) {
Write-Host "β
All core services are healthy" -ForegroundColor Green
} else {
Write-Host "β οΈ Some services may not be fully ready, but continuing..." -ForegroundColor Yellow
}
# Step 7: Seed database
Write-Host ""
Write-Host "π± Step 7: Seeding Neo4j database..." -ForegroundColor Blue
docker-compose exec mcp python /app/ops/scripts/seed.py
if ($LASTEXITCODE -eq 0) {
Write-Host "β
Database seeded successfully" -ForegroundColor Green
} else {
Write-Host "β Database seeding failed" -ForegroundColor Red
Write-Host " You can try manual seeding later with:" -ForegroundColor Gray
Write-Host " docker-compose exec mcp python /app/ops/scripts/seed.py" -ForegroundColor Gray
}
# Step 8: Final status check
Write-Host ""
Write-Host "π Step 8: Final status check..." -ForegroundColor Blue
docker-compose ps
# Step 9: Success message
Write-Host ""
Write-Host "π DEPLOYMENT COMPLETE!" -ForegroundColor Green
Write-Host "======================" -ForegroundColor Green
Write-Host ""
Write-Host "π± Access Points:" -ForegroundColor Yellow
Write-Host " β’ Frontend Interface: http://localhost:3000" -ForegroundColor White
Write-Host " β’ Neo4j Browser: http://localhost:7474" -ForegroundColor White
Write-Host " Login: neo4j / password" -ForegroundColor Gray
Write-Host ""
Write-Host "π§ Management Commands:" -ForegroundColor Yellow
Write-Host " β’ View logs: docker-compose logs -f" -ForegroundColor White
Write-Host " β’ Stop system: docker-compose down" -ForegroundColor White
Write-Host " β’ Check health: docker-compose ps" -ForegroundColor White
Write-Host ""
Write-Host "π― Quick Test:" -ForegroundColor Yellow
Write-Host " 1. Open http://localhost:3000" -ForegroundColor White
Write-Host " 2. Ask: ""How many customers do we have?""" -ForegroundColor White
Write-Host " 3. Watch the agent process the workflow!" -ForegroundColor White
Write-Host ""
if ($ApiKey -eq "") {
Write-Host "β οΈ REMINDER: Update your LLM API key in .env before testing!" -ForegroundColor Yellow
Write-Host ""
}
Write-Host "System is ready for use!" -ForegroundColor Green
|