mirror of
https://codeberg.org/likwid/likwid.git
synced 2026-02-09 13:03:10 +00:00
chore: fix dev scripts compose output and frontend test command
This commit is contained in:
parent
a0d412b5ff
commit
a11543a5f9
3 changed files with 122 additions and 122 deletions
|
|
@ -29,13 +29,13 @@ function Invoke-Compose {
|
|||
|
||||
$podmanCompose = Get-Command podman-compose -ErrorAction SilentlyContinue
|
||||
if ($podmanCompose) {
|
||||
& podman-compose @Args
|
||||
$null = & podman-compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
$podman = Get-Command podman -ErrorAction SilentlyContinue
|
||||
if ($podman) {
|
||||
& podman compose @Args
|
||||
$null = & podman compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,119 +1,119 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Stops the Likwid development environment.
|
||||
.DESCRIPTION
|
||||
Gracefully stops backend, frontend, and PostgreSQL container.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$stateDir = Join-Path $PSScriptRoot '.dev'
|
||||
$stateFile = Join-Path $stateDir 'state.json'
|
||||
$rootPattern = [regex]::Escape($root)
|
||||
|
||||
function Invoke-Compose {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string[]]$Args
|
||||
)
|
||||
|
||||
$podmanCompose = Get-Command podman-compose -ErrorAction SilentlyContinue
|
||||
if ($podmanCompose) {
|
||||
& podman-compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
$podman = Get-Command podman -ErrorAction SilentlyContinue
|
||||
if ($podman) {
|
||||
& podman compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
throw 'Neither podman-compose nor podman was found in PATH.'
|
||||
}
|
||||
|
||||
function Get-CommandLine {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][int]$ProcessId
|
||||
)
|
||||
|
||||
try {
|
||||
$p = Get-CimInstance Win32_Process -Filter "ProcessId=$ProcessId" -ErrorAction Stop
|
||||
return $p.CommandLine
|
||||
} catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
function Stop-ProcessSafely([int]$ProcessId, [string]$Name) {
|
||||
if (-not $ProcessId) { return $false }
|
||||
|
||||
$proc = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
if (-not $proc) { return $false }
|
||||
|
||||
Write-Host "Stopping $Name (PID $ProcessId)..."
|
||||
Stop-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Milliseconds 500
|
||||
|
||||
# Force kill if still running
|
||||
$proc = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
if ($proc) {
|
||||
Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
return $true
|
||||
}
|
||||
|
||||
function Stop-ProcessOnPort([int]$Port) {
|
||||
$connections = netstat -ano 2>$null | Select-String ":$Port.*LISTENING"
|
||||
foreach ($conn in $connections) {
|
||||
$parts = ($conn.Line -replace '\s+', ' ').Trim().Split(' ')
|
||||
$procId = [int]$parts[-1]
|
||||
if ($procId -gt 0) {
|
||||
$cmd = Get-CommandLine -ProcessId $procId
|
||||
$looksLikeLikwid = $false
|
||||
if ($cmd) {
|
||||
if ($cmd -match $rootPattern) { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'npm run dev') { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'astro') { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'cargo') { $looksLikeLikwid = $true }
|
||||
}
|
||||
|
||||
if ($looksLikeLikwid) {
|
||||
Stop-ProcessSafely -ProcessId $procId -Name "process on port $Port" | Out-Null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "=== Stopping Likwid Dev Environment ==="
|
||||
|
||||
# Stop from saved state
|
||||
if (Test-Path $stateFile) {
|
||||
$state = Get-Content -Raw $stateFile | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||
if ($state) {
|
||||
Stop-ProcessSafely -ProcessId $state.frontendPid -Name 'Frontend' | Out-Null
|
||||
Stop-ProcessSafely -ProcessId $state.backendPid -Name 'Backend' | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
# Cleanup any orphaned processes on the ports
|
||||
Stop-ProcessOnPort -Port 4321
|
||||
Stop-ProcessOnPort -Port 3000
|
||||
|
||||
# Stop PostgreSQL container
|
||||
Write-Host "Stopping PostgreSQL container..."
|
||||
$composeFile = Join-Path $root 'compose/dev.yml'
|
||||
try {
|
||||
Invoke-Compose -Args @('-f', $composeFile, 'down') | Out-Null
|
||||
} catch {
|
||||
}
|
||||
|
||||
# Clean up state file
|
||||
if (Test-Path $stateFile) {
|
||||
Remove-Item -Force $stateFile
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "All services stopped."
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Stops the Likwid development environment.
|
||||
.DESCRIPTION
|
||||
Gracefully stops backend, frontend, and PostgreSQL container.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$stateDir = Join-Path $PSScriptRoot '.dev'
|
||||
$stateFile = Join-Path $stateDir 'state.json'
|
||||
$rootPattern = [regex]::Escape($root)
|
||||
|
||||
function Invoke-Compose {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string[]]$Args
|
||||
)
|
||||
|
||||
$podmanCompose = Get-Command podman-compose -ErrorAction SilentlyContinue
|
||||
if ($podmanCompose) {
|
||||
$null = & podman-compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
$podman = Get-Command podman -ErrorAction SilentlyContinue
|
||||
if ($podman) {
|
||||
$null = & podman compose @Args
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
throw 'Neither podman-compose nor podman was found in PATH.'
|
||||
}
|
||||
|
||||
function Get-CommandLine {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][int]$ProcessId
|
||||
)
|
||||
|
||||
try {
|
||||
$p = Get-CimInstance Win32_Process -Filter "ProcessId=$ProcessId" -ErrorAction Stop
|
||||
return $p.CommandLine
|
||||
} catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
function Stop-ProcessSafely([int]$ProcessId, [string]$Name) {
|
||||
if (-not $ProcessId) { return $false }
|
||||
|
||||
$proc = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
if (-not $proc) { return $false }
|
||||
|
||||
Write-Host "Stopping $Name (PID $ProcessId)..."
|
||||
Stop-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Milliseconds 500
|
||||
|
||||
# Force kill if still running
|
||||
$proc = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
if ($proc) {
|
||||
Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
return $true
|
||||
}
|
||||
|
||||
function Stop-ProcessOnPort([int]$Port) {
|
||||
$connections = netstat -ano 2>$null | Select-String ":$Port.*LISTENING"
|
||||
foreach ($conn in $connections) {
|
||||
$parts = ($conn.Line -replace '\s+', ' ').Trim().Split(' ')
|
||||
$procId = [int]$parts[-1]
|
||||
if ($procId -gt 0) {
|
||||
$cmd = Get-CommandLine -ProcessId $procId
|
||||
$looksLikeLikwid = $false
|
||||
if ($cmd) {
|
||||
if ($cmd -match $rootPattern) { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'npm run dev') { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'astro') { $looksLikeLikwid = $true }
|
||||
if ($cmd -match 'cargo') { $looksLikeLikwid = $true }
|
||||
}
|
||||
|
||||
if ($looksLikeLikwid) {
|
||||
Stop-ProcessSafely -ProcessId $procId -Name "process on port $Port" | Out-Null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "=== Stopping Likwid Dev Environment ==="
|
||||
|
||||
# Stop from saved state
|
||||
if (Test-Path $stateFile) {
|
||||
$state = Get-Content -Raw $stateFile | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||
if ($state) {
|
||||
Stop-ProcessSafely -ProcessId $state.frontendPid -Name 'Frontend' | Out-Null
|
||||
Stop-ProcessSafely -ProcessId $state.backendPid -Name 'Backend' | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
# Cleanup any orphaned processes on the ports
|
||||
Stop-ProcessOnPort -Port 4321
|
||||
Stop-ProcessOnPort -Port 3000
|
||||
|
||||
# Stop PostgreSQL container
|
||||
Write-Host "Stopping PostgreSQL container..."
|
||||
$composeFile = Join-Path $root 'compose/dev.yml'
|
||||
try {
|
||||
Invoke-Compose -Args @('-f', $composeFile, 'down') | Out-Null
|
||||
} catch {
|
||||
}
|
||||
|
||||
# Clean up state file
|
||||
if (Test-Path $stateFile) {
|
||||
Remove-Item -Force $stateFile
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "All services stopped."
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ if ($Frontend -or $All) {
|
|||
Write-Host "=== Frontend Tests ===" -ForegroundColor Cyan
|
||||
Push-Location (Join-Path $root 'frontend')
|
||||
try {
|
||||
npm run check 2>&1 | Tee-Object -Variable frontendOutput
|
||||
npm run build 2>&1 | Tee-Object -Variable frontendOutput
|
||||
$results += @{ Component = 'Frontend'; Success = ($LASTEXITCODE -eq 0) }
|
||||
} finally {
|
||||
Pop-Location
|
||||
|
|
|
|||
Loading…
Reference in a new issue