Restart without reboot; retrievable logs incl. mpv exit reasons

Two related gaps on the headless kiosk: no way to restart the wall short
of a full reboot, and no way to see why a stream keeps flapping (the
daemon's stderr goes to sway on tty1, and mpv's stderr was discarded).

Restart in place:
- `rtsp-streamer restart` sends a control-socket command; the daemon
  tears down its mpv children and syscall.Exec's the on-disk binary.
  Same PID, same parent (sway), same env — keeps WAYLAND_DISPLAY/
  SWAYSOCK and comes back up on the new binary, no reboot. Handles the
  os.Executable() "(deleted)" sentinel from make install's rename.
- sway config now launches the daemon in a relaunch loop, so a crash (or
  the restart) auto-recovers instead of leaving a black screen.
- `make deploy` now does `install` + `restart` instead of restarting
  getty@tty1 (which left stale duplicate sessions and forced reboots).

Retrievable logs:
- New internal/logbuf ring; the daemon tees slog output into it and
  serves the tail over the socket via `rtsp-streamer logs [-n N]` —
  readable over SSH, no file wrangling, no reboot.
- Capture the tail of each mpv's stderr and log its last line when the
  process exits, so "mpv exited, will restart" now carries the reason
  (connection refused, unsupported codec, 401, ...). This is the
  diagnostic for a single tile going unhealthy repeatedly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Woodard
2026-07-02 10:03:25 -05:00
parent 9985a93851
commit be1b53ae04
10 changed files with 308 additions and 33 deletions

View File

@@ -19,9 +19,6 @@ DESTBIN := $(PREFIX)/bin/$(BINARY)
# `make deploy` work whether or not you prefix them with sudo.
SUDO := $(shell [ "$$(id -u)" -eq 0 ] || echo sudo)
# The kiosk session unit restarted by `make deploy`.
KIOSK_UNIT ?= getty@tty1
.PHONY: all build pi pi32 test vet clean run-tui install deploy uninstall
all: build
@@ -44,10 +41,12 @@ install: build
$(SUDO) install -m 0755 $(BINDIR)/$(BINARY) $(DESTBIN)
@echo "installed -> $(DESTBIN)"
## deploy: install, then restart the kiosk session so the wall picks it up
## deploy: install, then restart the running wall in place (no reboot). Run as
## the kiosk user so it reaches the daemon's control socket. Falls back to a
## note if the daemon isn't up yet (it will start on next boot).
deploy: install
$(SUDO) systemctl restart $(KIOSK_UNIT)
@echo "restarted $(KIOSK_UNIT); run 'rtsp-streamer status' to check"
@$(DESTBIN) restart || echo "daemon not running; it will start on next boot"
@echo "run 'rtsp-streamer status' to check"
## uninstall: remove the installed binary
uninstall: