-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgateway.ps1
More file actions
23 lines (22 loc) · 1.1 KB
/
Copy pathgateway.ps1
File metadata and controls
23 lines (22 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# VaderShell — Discord gateway launcher + supervisor.
#
# Loops so the gateway can reboot itself:
# /restart in Discord -> gateway exits 42 -> relaunch (reconnects in a few seconds)
# a crash (other exit) -> auto-relaunch, up to 5 times, with a short backoff
# a clean exit (0) -> stop
# So you can reboot the bot from your phone, even away from the machine.
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$env:PYTHONPATH = $root
# Gateway runs on Opus 4.7 (legacy). Override with VADER_CLAUDE_MODEL in .env.
$env:VADER_CLAUDE_MODEL = "claude-opus-4-7"
$crashes = 0
while ($true) {
& "$root\.venv\Scripts\python.exe" -m vader.gateway_discord
$code = $LASTEXITCODE
if ($code -eq 42) { Write-Host "[supervisor] /restart -> relaunching..."; $crashes = 0; continue }
if ($code -eq 0) { Write-Host "[supervisor] clean exit -> stopping."; break }
$crashes++
if ($crashes -ge 5) { Write-Host "[supervisor] too many crashes ($crashes) -> stopping."; break }
Write-Host "[supervisor] gateway exited ($code) -> relaunching in 3s (crash $crashes/5)..."
Start-Sleep -Seconds 3
}