Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions create-startup-shortcuts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
Installs (or removes) startup shortcuts so both watchdogs launch automatically,
minimized to the taskbar, when you log in.

- Runs at LOGON in your interactive desktop session (fires on Windows auto-login,
so no username/password is required — unlike a "run whether logged on or not"
boot task, which would need stored credentials).
- Non-elevated, matching how the watchdogs are normally run by hand. This also
avoids the elevated-orphan-worker problem seen with /RL HIGHEST tasks.
- Minimized window (not hidden) so the daily restart scripts can still find the
console by title and send WM_CLOSE for a clean llama-server shutdown.

Usage:
.\create-startup-shortcuts.ps1 # install
.\create-startup-shortcuts.ps1 -Remove # uninstall
#>
param([switch]$Remove)

$ErrorActionPreference = "Stop"
$scriptDir = Split-Path $PSCommandPath -Parent
$startup = [Environment]::GetFolderPath('Startup')

# WindowStyle for .lnk: 1 = Normal, 3 = Maximized, 7 = Minimized
$MINIMIZED = 7

$shortcuts = @(
@{ Name = "LLAMA Chat Watchdog"; Script = "watchdog.ps1" }
@{ Name = "LLAMA Embed Watchdog"; Script = "watchdog-embed.ps1" }
)

if ($Remove) {
foreach ($s in $shortcuts) {
$lnk = Join-Path $startup "$($s.Name).lnk"
if (Test-Path $lnk) {
Remove-Item $lnk -Force
Write-Host "[OK] Removed $lnk" -ForegroundColor Green
} else {
Write-Host "[--] Not present: $lnk" -ForegroundColor DarkGray
}
}
return
}

$wsh = New-Object -ComObject WScript.Shell

foreach ($s in $shortcuts) {
$target = Join-Path $scriptDir $s.Script
if (-not (Test-Path $target)) { throw "Watchdog script not found: $target" }

$lnkPath = Join-Path $startup "$($s.Name).lnk"
$lnk = $wsh.CreateShortcut($lnkPath)
$lnk.TargetPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
$lnk.Arguments = "-NoProfile -ExecutionPolicy Bypass -NoExit -File `"$target`""
$lnk.WorkingDirectory = $scriptDir
$lnk.WindowStyle = $MINIMIZED
$lnk.Description = "Auto-start $($s.Script) minimized at logon"
$lnk.Save()
Write-Host "[OK] Installed $lnkPath (minimized, launches $($s.Script))" -ForegroundColor Green
}

Write-Host ""
Write-Host "Startup folder: $startup"
Write-Host "They will launch minimized on your next login. To start them now:"
Write-Host " Start-Process powershell -WindowStyle Minimized -ArgumentList '-NoProfile','-NoExit','-File','$(Join-Path $scriptDir "watchdog.ps1")'"
Write-Host " Start-Process powershell -WindowStyle Minimized -ArgumentList '-NoProfile','-NoExit','-File','$(Join-Path $scriptDir "watchdog-embed.ps1")'"
Write-Host ""
Write-Host "To remove: .\create-startup-shortcuts.ps1 -Remove"
4 changes: 2 additions & 2 deletions restart-watchdog-embed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ if (-not $found) {
# --- Brief pause before restart to let ports fully release ---
Start-Sleep -Seconds 3

# --- Launch fresh embed watchdog in a visible console ---
# --- Launch fresh embed watchdog in a minimized console ---
Log "Starting fresh embed watchdog"
Start-Process powershell -WindowStyle Normal `
Start-Process powershell -WindowStyle Minimized `
-ArgumentList "-NoExit", "-NoProfile", "-File", "`"$watchdog`"" `
-WorkingDirectory $scriptDir

Expand Down
4 changes: 2 additions & 2 deletions restart-watchdog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ if (-not $found) {
# --- Brief pause before restart to let ports fully release ---
Start-Sleep -Seconds 3

# --- Launch fresh watchdog in a visible console ---
# --- Launch fresh watchdog in a minimized console ---
Log "Starting fresh watchdog"
Start-Process powershell -WindowStyle Normal `
Start-Process powershell -WindowStyle Minimized `
-ArgumentList "-NoExit", "-NoProfile", "-File", "`"$watchdog`"" `
-WorkingDirectory $scriptDir

Expand Down
6 changes: 6 additions & 0 deletions watchdog-embed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# Usage: .\watchdog-embed.ps1 [extra args forwarded to embed_proxy.py]

$ErrorActionPreference = "Stop"

# Stable console title so the daily restart scripts can find this window by
# title (matches *embed*, and deliberately contains no "watchdog" so the chat
# restart never catches this window). Also survives minimized launches.
$host.UI.RawUI.WindowTitle = "llama-embed-supervisor"

$scriptDir = Split-Path $PSCommandPath -Parent
$python = Join-Path $scriptDir ".venv\Scripts\python.exe"
$proxy = Join-Path $scriptDir "embed_proxy.py"
Expand Down
6 changes: 6 additions & 0 deletions watchdog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
# --model and --ctx-size only set the fallback when a client omits the model.

$ErrorActionPreference = "Stop"

# Stable console title so the daily restart scripts can find this window by
# title (matches *watchdog*, and deliberately contains no "embed" so the chat
# restart never catches the embed watchdog). Also survives minimized launches.
$host.UI.RawUI.WindowTitle = "llama-chat-watchdog"

$scriptDir = Split-Path $PSCommandPath -Parent
$python = Join-Path $scriptDir ".venv\Scripts\python.exe"
$proxy = Join-Path $scriptDir "proxy.py"
Expand Down