11param (
2- [ValidateSet (" run " , " stop" , " build" , " clean-data" , " console" , " logs" , " status" , " help" )]
2+ [ValidateSet (" start " , " stop" , " build" , " clean-data" , " console" , " logs" , " status" , " help" )]
33 [string ]$Command = " help" ,
44 [string ]$ServiceName = " " ,
55 [switch ]$Follow ,
@@ -23,7 +23,7 @@ function Show-Help {
2323 Write-Host " .\launcher.ps1 <command>" - ForegroundColor White
2424 Write-Host " "
2525 Write-Host " COMMANDS:" - ForegroundColor $InfoColor
26- Write-Host " run Start the Docker stack" - ForegroundColor White
26+ Write-Host " start Start the Docker stack" - ForegroundColor White
2727 Write-Host " stop Stop the running Docker stack" - ForegroundColor White
2828 Write-Host " build Build and start the Docker stack" - ForegroundColor White
2929 Write-Host " clean-data Clean all user data and stop containers" - ForegroundColor White
@@ -86,6 +86,55 @@ function Convert-ShellScriptsToLF {
8686 }
8787}
8888
89+ function Wait-ForHealthyServices {
90+ Write-Host " Waiting for backend and frontend to be healthy..." - ForegroundColor $InfoColor
91+
92+ $maxAttempts = 60
93+ $attempt = 0
94+ $backendHealthy = $false
95+ $frontendHealthy = $false
96+
97+ while ($attempt -lt $maxAttempts ) {
98+ $attempt ++
99+
100+ if (-not $backendHealthy ) {
101+ $backendHealth = Invoke-Expression " docker compose ps --format json sentinel-kit-app-backend" - ErrorAction SilentlyContinue
102+ if ($LASTEXITCODE -eq 0 -and $backendHealth ) {
103+ $healthStatus = ($backendHealth | ConvertFrom-Json ).Health
104+ if ($healthStatus -eq " healthy" ) {
105+ Write-Host " Backend is healthy!" - ForegroundColor $SuccessColor
106+ $backendHealthy = $true
107+ }
108+ }
109+ }
110+
111+ if (-not $frontendHealthy ) {
112+ $frontendHealth = Invoke-Expression " docker compose ps --format json sentinel-kit-app-frontend" - ErrorAction SilentlyContinue
113+ if ($LASTEXITCODE -eq 0 -and $frontendHealth ) {
114+ $healthStatus = ($frontendHealth | ConvertFrom-Json ).Health
115+ if ($healthStatus -eq " healthy" ) {
116+ Write-Host " Frontend is healthy!" - ForegroundColor $SuccessColor
117+ $frontendHealthy = $true
118+ }
119+ }
120+ }
121+
122+ if ($backendHealthy -and $frontendHealthy ) {
123+ Write-Host " All critical services are healthy and ready!" - ForegroundColor $SuccessColor
124+ return $true
125+ }
126+
127+ if ($attempt % 10 -eq 0 ) {
128+ Write-Host " Still waiting... (attempt $attempt /$maxAttempts )" - ForegroundColor $WarningColor
129+ }
130+
131+ Start-Sleep - Seconds 10
132+ }
133+
134+ Write-Host " Timeout: Services did not become healthy within the expected time." - ForegroundColor $ErrorColor
135+ return $false
136+ }
137+
89138if ($Help ) {
90139 Show-Help
91140 exit 0
@@ -95,7 +144,7 @@ switch ($Command.ToLower()) {
95144 " help" {
96145 Show-Help
97146 }
98- " run " {
147+ " start " {
99148 Write-Host " "
100149 Write-Host " ========== STARTING SENTINELKIT ==========" - ForegroundColor $HeaderColor
101150
@@ -109,12 +158,21 @@ switch ($Command.ToLower()) {
109158
110159 if ($RunningContainers ) {
111160 Write-Host " Docker stack is already running." - ForegroundColor $InfoColor
161+ if (Wait-ForHealthyServices ) {
162+ Write-Host " Success! The Docker stack is running and healthy." - ForegroundColor $SuccessColor
163+ } else {
164+ Write-Host " Warning: Some services may not be fully healthy yet." - ForegroundColor $WarningColor
165+ }
112166 } else {
113167 Write-Host " Starting the Docker stack..." - ForegroundColor $InfoColor
114168 Invoke-Expression " docker compose up -d"
115169
116170 if ($LASTEXITCODE -eq 0 ) {
117- Write-Host " Success! The Docker stack has been launched." - ForegroundColor $SuccessColor
171+ if (Wait-ForHealthyServices ) {
172+ Write-Host " Success! The Docker stack has been launched and is healthy." - ForegroundColor $SuccessColor
173+ } else {
174+ Write-Host " Warning: Docker stack started but some services are not healthy." - ForegroundColor $WarningColor
175+ }
118176 } else {
119177 Write-Host " Error starting containers." - ForegroundColor $ErrorColor
120178 }
@@ -157,7 +215,11 @@ switch ($Command.ToLower()) {
157215 Invoke-Expression " docker compose up -d --build --force-recreate"
158216
159217 if ($LASTEXITCODE -eq 0 ) {
160- Write-Host " Success! The Docker stack has been built and started." - ForegroundColor $SuccessColor
218+ if (Wait-ForHealthyServices ) {
219+ Write-Host " Success! The Docker stack has been built, started and is healthy." - ForegroundColor $SuccessColor
220+ } else {
221+ Write-Host " Warning: Docker stack built and started but some services are not healthy." - ForegroundColor $WarningColor
222+ }
161223 } else {
162224 Write-Host " Error building containers." - ForegroundColor $ErrorColor
163225 }
@@ -174,7 +236,7 @@ switch ($Command.ToLower()) {
174236
175237 if (-not $backendContainer ) {
176238 Write-Host " Backend container is not running." - ForegroundColor $ErrorColor
177- Write-Host " Please start the stack first using: .\launcher.ps1 run " - ForegroundColor $WarningColor
239+ Write-Host " Please start the stack first using: .\launcher.ps1 start " - ForegroundColor $WarningColor
178240 exit 1
179241 }
180242
@@ -311,9 +373,14 @@ switch ($Command.ToLower()) {
311373 Write-Host " Starting cleanup process..." - ForegroundColor $WarningColor
312374
313375 $itemsToRemove = @ (
376+ " ./sentinel-kit_server_frontend/.production_build_complete" ,
377+ " ./sentinel-kit_server_frontend/.source_hash" ,
314378 " ./sentinel-kit_server_frontend/node_modules" ,
315379 " ./sentinel-kit_server_frontend/package-lock.json" ,
316380 " ./sentinel-kit_server_frontend/dist" ,
381+ " ./sentinel-kit_server_backend/.cache_ready" ,
382+ " ./sentinel-kit_server_backend/.composer_hash" ,
383+ " ./sentinel-kit_server_backend/.source_hash" ,
317384 " ./sentinel-kit_server_backend/.initial_setup_done" ,
318385 " ./sentinel-kit_server_backend/composer.lock" ,
319386 " ./sentinel-kit_server_backend/symfony.lock" ,
0 commit comments