-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_command_gating.ps1
More file actions
137 lines (112 loc) · 5.48 KB
/
deploy_command_gating.ps1
File metadata and controls
137 lines (112 loc) · 5.48 KB
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
#!/usr/bin/env pwsh
# Deploy Execute Command Gating to Production Droplet
# Usage: .\deploy_command_gating.ps1
$ErrorActionPreference = "Stop"
Write-Host "🚀 Deploying Execute Command Gating to Production Droplet" -ForegroundColor Cyan
Write-Host ""
# Configuration
$DROPLET_IP = "45.55.173.72"
$DROPLET_USER = "root"
$DEPLOY_PATH = "/opt/code-chef"
$COMPOSE_PATH = "/opt/code-chef/deploy"
$HEALTH_CHECK_URL = "https://codechef.appsmithery.co/health"
# Step 1: Commit and push changes
Write-Host "📝 Step 1: Committing and pushing changes..." -ForegroundColor Yellow
git add -A
git commit -m "feat: implement execute command gating with Linear orchestration"
git push origin main
Write-Host "✅ Changes committed and pushed" -ForegroundColor Green
Write-Host ""
# Step 2: Pull changes on droplet
Write-Host "📥 Step 2: Pulling changes on droplet..." -ForegroundColor Yellow
ssh ${DROPLET_USER}@${DROPLET_IP} "cd ${DEPLOY_PATH} && git pull"
Write-Host "✅ Changes pulled" -ForegroundColor Green
Write-Host ""
# Step 3: Restart services
Write-Host "🔄 Step 3: Restarting services..." -ForegroundColor Yellow
Write-Host "This will cause ~30s of downtime" -ForegroundColor Gray
ssh ${DROPLET_USER}@${DROPLET_IP} "cd ${COMPOSE_PATH} && docker compose down && docker compose up -d"
Write-Host "✅ Services restarted" -ForegroundColor Green
Write-Host ""
# Step 4: Wait for services to be ready
Write-Host "⏳ Step 4: Waiting for services to be ready (60s)..." -ForegroundColor Yellow
Start-Sleep -Seconds 60
# Step 5: Health check
Write-Host "🏥 Step 5: Running health checks..." -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri $HEALTH_CHECK_URL -Method Get
if ($response.status -eq "ok") {
Write-Host "✅ Health check passed!" -ForegroundColor Green
Write-Host " Service: $($response.service)" -ForegroundColor Gray
Write-Host " Version: $($response.version)" -ForegroundColor Gray
# Check dependencies
if ($response.dependencies) {
Write-Host " Dependencies:" -ForegroundColor Gray
$response.dependencies.PSObject.Properties | ForEach-Object {
$color = if ($_.Value -eq "connected") { "Green" } else { "Red" }
Write-Host " - $($_.Name): $($_.Value)" -ForegroundColor $color
}
}
}
else {
Write-Host "❌ Health check failed: $($response.status)" -ForegroundColor Red
exit 1
}
}
catch {
Write-Host "❌ Health check failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host ""
# Step 6: Test command parsing
Write-Host "🧪 Step 6: Testing command parsing..." -ForegroundColor Yellow
# This would require the API endpoint to be accessible
# For now, just check logs
Write-Host "Checking logs for command parser initialization..." -ForegroundColor Gray
ssh ${DROPLET_USER}@${DROPLET_IP} "docker logs deploy-orchestrator-1 --tail=20 | grep -i command || true"
Write-Host ""
# Step 7: Monitor logs
Write-Host "📊 Step 7: Monitoring initial logs..." -ForegroundColor Yellow
Write-Host "Watching for errors in the first 30 seconds..." -ForegroundColor Gray
$logJob = Start-Job -ScriptBlock {
param($user, $ip)
ssh "${user}@${ip}" "docker logs -f deploy-orchestrator-1 2>&1 | head -n 50"
} -ArgumentList $DROPLET_USER, $DROPLET_IP
Start-Sleep -Seconds 30
Stop-Job -Job $logJob
$logs = Receive-Job -Job $logJob
if ($logs -match "ERROR") {
Write-Host "⚠️ Errors detected in logs:" -ForegroundColor Yellow
$logs | Select-String "ERROR" | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
}
else {
Write-Host "✅ No errors detected in initial logs" -ForegroundColor Green
}
Remove-Job -Job $logJob
Write-Host ""
# Step 8: Summary
Write-Host "=" * 80 -ForegroundColor Cyan
Write-Host "✅ DEPLOYMENT COMPLETE!" -ForegroundColor Green
Write-Host "=" * 80 -ForegroundColor Cyan
Write-Host ""
Write-Host "📋 What Was Deployed:" -ForegroundColor Yellow
Write-Host " • Command parser (/execute, /help, /status, /cancel)" -ForegroundColor White
Write-Host " • Conversational mode for /chat/stream" -ForegroundColor White
Write-Host " • Linear issue orchestration" -ForegroundColor White
Write-Host " • Supervisor routing with subissues" -ForegroundColor White
Write-Host " • Real-time Linear state updates" -ForegroundColor White
Write-Host ""
Write-Host "📚 Documentation:" -ForegroundColor Yellow
Write-Host " • Migration Guide: support/docs/COMMAND-GATING-MIGRATION.md" -ForegroundColor White
Write-Host " • Implementation: support/docs/COMMAND-GATING-IMPLEMENTATION.md" -ForegroundColor White
Write-Host ""
Write-Host "🔍 Next Steps:" -ForegroundColor Yellow
Write-Host " 1. Test /execute command in VS Code extension" -ForegroundColor White
Write-Host " 2. Verify Linear issue creation" -ForegroundColor White
Write-Host " 3. Monitor logs for 24 hours: ssh root@45.55.173.72 'docker logs -f deploy-orchestrator-1'" -ForegroundColor White
Write-Host " 4. Check Linear project for new issues: https://linear.app/..." -ForegroundColor White
Write-Host ""
Write-Host "🚨 Rollback (if needed):" -ForegroundColor Yellow
Write-Host " ssh root@45.55.173.72 'cd /opt/code-chef && git log --oneline | head -5 && git checkout <prev-commit> && docker compose down && docker compose up -d'" -ForegroundColor White
Write-Host ""
Write-Host "🎉 Happy coding!" -ForegroundColor Cyan