mirror of
https://codeberg.org/likwid/likwid.git
synced 2026-02-09 13:03:10 +00:00
66 lines
2.2 KiB
PowerShell
66 lines
2.2 KiB
PowerShell
# Demo Reset Script (Windows PowerShell)
|
|
# Resets the demo instance to a clean state with fresh seed data
|
|
|
|
param(
|
|
[switch]$Force
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "=== Likwid Demo Reset ===" -ForegroundColor Cyan
|
|
|
|
if (-not $Force) {
|
|
$confirm = Read-Host "This will DELETE all demo data and reset to initial state. Continue? (y/N)"
|
|
if ($confirm -ne "y" -and $confirm -ne "Y") {
|
|
Write-Host "Aborted." -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
}
|
|
|
|
Set-Location "$PSScriptRoot\.."
|
|
|
|
$envFile = "compose/.env.demo"
|
|
if (-not (Test-Path $envFile) -and (Test-Path "compose/.env.demo.example")) {
|
|
$envFile = "compose/.env.demo.example"
|
|
}
|
|
$composeArgs = @("-f", "compose/demo.yml")
|
|
if (Test-Path $envFile) {
|
|
$composeArgs = @("--env-file", $envFile) + $composeArgs
|
|
}
|
|
|
|
Write-Host "`n[1/3] Stopping demo containers and removing volumes..." -ForegroundColor Yellow
|
|
podman-compose @composeArgs down --remove-orphans -v
|
|
|
|
Write-Host "`n[2/3] Starting fresh demo instance..." -ForegroundColor Yellow
|
|
podman-compose @composeArgs up -d
|
|
|
|
Write-Host "`n[3/3] Waiting for services to be ready..." -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 10
|
|
|
|
# Check if backend is responding
|
|
$maxRetries = 30
|
|
$retry = 0
|
|
while ($retry -lt $maxRetries) {
|
|
try {
|
|
$response = Invoke-WebRequest -Uri "http://localhost:3001/health" -UseBasicParsing -TimeoutSec 2
|
|
if ($response.StatusCode -eq 200) {
|
|
Write-Host "`n=== Demo Reset Complete ===" -ForegroundColor Green
|
|
Write-Host "`nDemo is ready at:"
|
|
Write-Host " Frontend: http://localhost:4322" -ForegroundColor Cyan
|
|
Write-Host " Backend: http://localhost:3001" -ForegroundColor Cyan
|
|
Write-Host "`nDemo accounts (password: demo123):"
|
|
Write-Host " - contributor (standard member)"
|
|
Write-Host " - moderator (can moderate)"
|
|
Write-Host " - observer (read-only)"
|
|
exit 0
|
|
}
|
|
} catch {
|
|
$retry++
|
|
Write-Host "." -NoNewline
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
}
|
|
|
|
Write-Host "`nWarning: Backend health check timed out. Check logs with:" -ForegroundColor Yellow
|
|
$composeArgsText = ($composeArgs -join ' ')
|
|
Write-Host " podman-compose $composeArgsText logs backend"
|