File size: 937 Bytes
f25362a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[CmdletBinding()]
param()
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$RunDir = Join-Path $Root ".jackailocal\run"

function Stop-PidFile([string]$Path) {
  if (!(Test-Path $Path)) { return }
  $pidText = (Get-Content -Raw -Path $Path).Trim()
  $pidValue = 0
  if ([int]::TryParse($pidText, [ref]$pidValue)) {
    $process = Get-Process -Id $pidValue -ErrorAction SilentlyContinue
    if ($process) {
      Stop-Process -Id $pidValue -Force -ErrorAction SilentlyContinue
    }
  }
  Remove-Item -LiteralPath $Path -Force -ErrorAction SilentlyContinue
}

Stop-PidFile (Join-Path $RunDir "jackailocald.pid")
Stop-PidFile (Join-Path $RunDir "ollama.pid")

Get-Process jackailocald,ollama,llama-server -ErrorAction SilentlyContinue |
  Where-Object { $_.Path -and $_.Path.StartsWith($Root, [System.StringComparison]::OrdinalIgnoreCase) } |
  Stop-Process -Force -ErrorAction SilentlyContinue
Write-Host "JackAILocal stopped."