mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 12:37:48 +01:00
27 lines
530 B
PowerShell
27 lines
530 B
PowerShell
# https://chatgpt.com/c/681762a4-dddc-800a-adad-2797355013f8
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$PIDFILE = Join-Path $PSScriptRoot ".pid"
|
|
|
|
if (-Not (Test-Path $PIDFILE)) {
|
|
Write-Host "Not running"
|
|
exit 2
|
|
}
|
|
|
|
$ReadPID = Get-Content $PIDFILE
|
|
|
|
if (-Not (Get-Process -Id $ReadPID -ErrorAction SilentlyContinue)) {
|
|
Write-Host "Not running"
|
|
Remove-Item $PIDFILE -Force
|
|
exit 2
|
|
}
|
|
|
|
Write-Host "Killing $ReadPID"
|
|
|
|
# TODO: Graceful shutdown
|
|
|
|
Stop-Process -Id $ReadPID
|
|
|
|
Remove-Item $PIDFILE -Force
|