Spaces:
No application file
No application file
| # 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 | |