forked from MCKRUZ/microsoft-agentic-harness
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-services.ps1
More file actions
160 lines (132 loc) · 4.4 KB
/
Copy pathstart-services.ps1
File metadata and controls
160 lines (132 loc) · 4.4 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<#
.SYNOPSIS
Start all Agentic Harness infrastructure services
.DESCRIPTION
Starts the full observability stack in the correct order:
1. OTel Collector + Jaeger (creates shared Docker network)
2. Prometheus + Grafana (connects to shared network)
.PARAMETER OTelOnly
Start only the OTel Collector + Jaeger stack
.PARAMETER DashboardsOnly
Start only the Prometheus + Grafana stack (requires OTel stack running)
.EXAMPLE
.\start-services.ps1
Starts all services in background
.EXAMPLE
.\start-services.ps1 -OTelOnly
Starts only OTel Collector + Jaeger
#>
param(
[Parameter()]
[switch]$OTelOnly,
[Parameter()]
[switch]$DashboardsOnly
)
$ErrorActionPreference = "Stop"
$repoRoot = $PSScriptRoot
function Write-Success { param($Message) Write-Host "[OK] $Message" -ForegroundColor Green }
function Write-Info { param($Message) Write-Host "[..] $Message" -ForegroundColor Cyan }
function Write-Warn { param($Message) Write-Host "[!!] $Message" -ForegroundColor Yellow }
function Test-Docker {
try {
$null = docker --version 2>$null
$null = docker ps 2>$null
return $true
}
catch {
return $false
}
}
function Start-Stack {
param(
[string]$Path,
[string]$Name
)
Write-Info "Starting $Name..."
Push-Location $Path
try {
docker-compose up -d 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Success "$Name started"
}
else {
Write-Host "[!!] Failed to start $Name" -ForegroundColor Red
exit 1
}
}
finally {
Pop-Location
}
}
function Wait-Healthy {
param(
[string]$ContainerName,
[int]$TimeoutSeconds = 60
)
Write-Info "Waiting for $ContainerName to be healthy..."
$elapsed = 0
while ($elapsed -lt $TimeoutSeconds) {
$status = docker inspect --format '{{.State.Health.Status}}' $ContainerName 2>$null
if ($status -eq "healthy") {
Write-Success "$ContainerName is healthy"
return
}
if ($status -eq "") {
Write-Warn "$ContainerName has no health check, skipping wait"
return
}
Start-Sleep -Seconds 3
$elapsed += 3
}
Write-Warn "$ContainerName did not become healthy within ${TimeoutSeconds}s (current: $status)"
}
# Main
try {
Write-Host ""
Write-Host "Agentic Harness Services" -ForegroundColor Magenta
Write-Host ""
if (-not (Test-Docker)) {
Write-Host "[!!] Docker is not installed or not running" -ForegroundColor Red
exit 1
}
$otelDir = Join-Path $repoRoot "scripts\otel-collector"
$dashDir = Join-Path $repoRoot "Dashboards"
# Stack 1: OTel Collector + Jaeger
if (-not $DashboardsOnly) {
Start-Stack -Path $otelDir -Name "OTel Collector + Jaeger"
Wait-Healthy -ContainerName "agentic-harness-jaeger"
Write-Host ""
}
# Stack 2: Prometheus + Grafana
if (-not $OTelOnly) {
$network = docker network ls --filter "name=agentic-harness-otel" --format "{{.Name}}" 2>$null
if (-not $network) {
Write-Host "[!!] Network 'agentic-harness-otel' not found. Start OTel stack first." -ForegroundColor Red
Write-Host " Run: .\start-services.ps1" -ForegroundColor Gray
exit 1
}
Start-Stack -Path $dashDir -Name "Prometheus + Grafana"
Wait-Healthy -ContainerName "agentic-harness-prometheus"
Wait-Healthy -ContainerName "agentic-harness-grafana"
Write-Host ""
}
Write-Success "All services started!"
Write-Host ""
Write-Host "Endpoints:" -ForegroundColor Yellow
if (-not $DashboardsOnly) {
Write-Host " Jaeger UI: http://localhost:16686" -ForegroundColor Cyan
Write-Host " OTLP gRPC: http://localhost:4317" -ForegroundColor Cyan
Write-Host " OTLP HTTP: http://localhost:4318" -ForegroundColor Cyan
Write-Host " Collector Health: http://localhost:13133/health" -ForegroundColor Cyan
}
if (-not $OTelOnly) {
Write-Host " Grafana: http://localhost:3000 (admin/admin)" -ForegroundColor Cyan
Write-Host " Prometheus: http://localhost:9090" -ForegroundColor Cyan
}
Write-Host ""
}
catch {
Write-Host "[!!] Unexpected error: $_" -ForegroundColor Red
Write-Host $_.ScriptStackTrace -ForegroundColor DarkGray
exit 1
}