utils/system_one/scripts/kev_serve.sh
Krzysztof kuhy Rudnicki 13949dfd65
Some checks are pending
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
Add system_one; home_paths skips skills/synced
Lands 5906f2a from kuhy's ~/src/utils checkout, which was never pushed
under a mislabelled subject ("bump flutter_svg", already on origin):
- system_one/: GPU-yield and kev model services, bench, jevgrep skill.
- home_paths: treat ~/.claude/skills/synced copies as third-party.
The stray .claude/worktrees/gat gitlink is dropped, and .gitignore now
ignores .claude/worktrees/ so a harness worktree cannot ride in again.

Bug-class-check: .gitignore `.claude/worktrees/` (git check-ignore .claude/worktrees/x)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 12:37:07 +01:00

35 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# Serve one Kev checkpoint on a loopback port (foreground; systemd ExecStart).
# kev_serve.sh <checkpoint> <port> e.g. kev_serve.sh jaredpalmer/kev-4b@v1.0 8018
# Refuses to load while a game runs or VRAM is short (system_one.guard), so a
# socket-activated start can never take the GPU from a game.
# ============================================================================
set -euo pipefail
readonly KEV_DIR="${KEV_DIR:-$HOME/vendor/kev}"
readonly SYSTEM_ONE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
usage() {
echo "Usage: $(basename "$0") <checkpoint> <port> [need_mib]" >&2
exit 2
}
main() {
[[ $# -ge 2 ]] || usage
local checkpoint="$1" port="$2" need_mib="${3:-16000}"
if ! PYTHONPATH="$SYSTEM_ONE_DIR" python3 -m system_one.guard "$need_mib"; then
echo "kev_serve: GPU not available, not loading $checkpoint" >&2
exit 75 # EX_TEMPFAIL
fi
cd "$KEV_DIR"
# KEV_VRAM_MIB (set by the unit) = hard VRAM budget via kev_launch.py.
local -a entry=(-m kev.serve)
[[ -n "${KEV_VRAM_MIB:-}" ]] && entry=("$SYSTEM_ONE_DIR/system_one/kev_launch.py")
exec uv run --frozen --extra serve python "${entry[@]}" \
--run "$checkpoint" --host 127.0.0.1 --port "$port"
}
main "$@"