mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
Feat/add developer docs for windows (#213)
* docs: add windows commands for developer setup * feat: add windows scripts * fix(ui): make dev script cross-platform with cross-env * feat(scripts): enhance migration scripts for Alembic environment setup and add virtual environment activation
This commit is contained in:
parent
e7adbc7bad
commit
66b085dde2
10 changed files with 443 additions and 13 deletions
92
scripts/stop_services.ps1
Normal file
92
scripts/stop_services.ps1
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/env pwsh
|
||||
# Stop Dograh services started by start_services_dev.ps1 (Windows)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
###############################################################################
|
||||
### CONFIGURATION
|
||||
###############################################################################
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$BaseDir = Split-Path -Parent $ScriptDir
|
||||
$RunDir = Join-Path $BaseDir 'run'
|
||||
|
||||
Set-Location $BaseDir
|
||||
Write-Host "Stopping Dograh Services in BASE_DIR: $BaseDir"
|
||||
|
||||
###############################################################################
|
||||
### HELPER
|
||||
###############################################################################
|
||||
|
||||
function Stop-ProcessTree([int]$ProcessId) {
|
||||
# taskkill /T kills the entire process tree. Temporarily relax error
|
||||
# preference so that a "process not found" message on stderr does not
|
||||
# terminate the script.
|
||||
$prev = $ErrorActionPreference
|
||||
try {
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
& taskkill /PID $ProcessId /T /F 2>&1 | Out-Null
|
||||
} finally {
|
||||
$ErrorActionPreference = $prev
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
### STOP SERVICES
|
||||
###############################################################################
|
||||
|
||||
if (-not (Test-Path $RunDir)) {
|
||||
Write-Host "No run directory found at $RunDir"
|
||||
Write-Host "No services appear to be running."
|
||||
exit 0
|
||||
}
|
||||
|
||||
$pidFiles = Get-ChildItem $RunDir -Filter '*.pid' -ErrorAction SilentlyContinue
|
||||
if (-not $pidFiles) {
|
||||
Write-Host "No PID files found in $RunDir"
|
||||
Write-Host "No services appear to be running."
|
||||
exit 0
|
||||
}
|
||||
|
||||
$stoppedCount = 0
|
||||
$failedCount = 0
|
||||
|
||||
foreach ($pidFile in $pidFiles) {
|
||||
$name = $pidFile.BaseName
|
||||
$oldPid = (Get-Content $pidFile.FullName -Raw).Trim()
|
||||
|
||||
$proc = Get-Process -Id ([int]$oldPid) -ErrorAction SilentlyContinue
|
||||
if ($proc) {
|
||||
Write-Host "Stopping $name (PID $oldPid)..."
|
||||
Stop-ProcessTree ([int]$oldPid)
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
$still = Get-Process -Id ([int]$oldPid) -ErrorAction SilentlyContinue
|
||||
if ($still) {
|
||||
Write-Host " Warning: $name did not exit cleanly"
|
||||
$failedCount++
|
||||
} else {
|
||||
Write-Host " Stopped $name"
|
||||
$stoppedCount++
|
||||
}
|
||||
} else {
|
||||
# The tracked cmd.exe may have exited but child processes may still run.
|
||||
# Best-effort cleanup via taskkill tree kill.
|
||||
Stop-ProcessTree ([int]$oldPid)
|
||||
Write-Host "Service $name (PID $oldPid) is not running"
|
||||
}
|
||||
|
||||
Remove-Item $pidFile.FullName -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
### SUMMARY
|
||||
###############################################################################
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "------------------------------------------------------"
|
||||
Write-Host "Stopped $stoppedCount service(s)"
|
||||
if ($failedCount -gt 0) {
|
||||
Write-Host "Failed to stop $failedCount service(s)"
|
||||
}
|
||||
Write-Host "------------------------------------------------------"
|
||||
Loading…
Add table
Add a link
Reference in a new issue