feat(audiobookshelf): the audiobook server as a boot-persistent quadlet
Audiobookshelf serves /mnt/entropy/Audiobooks to browsers and phones with its own library and per-listener positions. The design point of the unit: every byte this server writes is its own state - SQLite library, accounts, progress, cached covers - and all of it lands on the NVMe under /home/dank/Containers/audiobookshelf. The audio bind is :ro, so a stray sidecar write onto the spindle is structurally impossible rather than merely discouraged, and the array keeps exactly one sanctioned write path (scripts/media-view.sh). Three failure modes the unit is shaped around: - Bind-source ordering. In a rootless unit RequiresMountsFor= is inert and ConditionPathIsMountPoint= is fail-dead, so a missing array does not stop the start: podman invents an empty directory and the first scan records an empty library as truth. ExecStartPre=wait-for-mount.sh is the gate that works here, the same one copyparty uses. - The health binary. The image is Alpine: wget, no curl. A curl HealthCmd reads a healthy server as unhealthy and Restart=always turns that into a loop. - The image pin. podman records the linux/amd64 manifest for what it pulled, not the manifest-list digest `latest` points at, so the amd64 digest is the pin that names the build this host runs. Upstream version tags stop at 2.19.0 while `latest` is newer, so latest@digest is the only form that is both current and exact - the jellyfin/romm precedent. The first-boot scan reads the whole tree once, so IOWeight=10 keeps it behind playback; that weight is only honoured because the user.slice accounting drop-in and the user@1000 delegation are installed by the deployer. Deployer registration is the standard four touch-points (client gate, remote allowlist + handler + dispatcher, planner order/set/path map, test routing). The handler creates both state roots before the first start - letting podman invent them leaves the SQLite file unwritable by the container user under a rootless first boot - and gates on /healthcheck.
This commit is contained in:
1 parent
29aefc3b6f
commit
511d8dca93
6 files changed
+133
-1
No files matched your search
@@ -127,3 +127,51 @@ load helpers
|
||||
grep -q "dankserver/host/systemd/$f" "$REPO_ROOT/scripts/deploy-remote.sh" || return 1
|
||||
done
|
||||
}
|
||||
|
||||
@test "audiobookshelf unit exists, is boot-persistent and self-healing" {
|
||||
unit="$REPO_ROOT/dankserver/audiobookshelf/quadlet/audiobookshelf.container"
|
||||
[ -f "$unit" ] || return 1
|
||||
grep -q '^WantedBy=default.target$' "$unit" || return 1
|
||||
grep -q '^Restart=always$' "$unit" || return 1
|
||||
grep -q '^RestartSec=' "$unit" || return 1
|
||||
}
|
||||
|
||||
@test "audiobookshelf keeps every byte it writes on the SSD" {
|
||||
# The point of the unit: its library database, accounts, progress and cached
|
||||
# covers are all server state, and server state belongs on the NVMe. A bind
|
||||
# of /mnt/entropy that is not :ro would silently put writes on the spindle.
|
||||
unit="$REPO_ROOT/dankserver/audiobookshelf/quadlet/audiobookshelf.container"
|
||||
grep -q '^Volume=/home/dank/Containers/audiobookshelf/config:/config$' "$unit" || return 1
|
||||
grep -q '^Volume=/home/dank/Containers/audiobookshelf/metadata:/metadata$' "$unit" || return 1
|
||||
grep -q '^Volume=/mnt/entropy/Audiobooks:/audiobooks:ro$' "$unit" || return 1
|
||||
# The overlay view is reserved for the two media servers that write sidecars
|
||||
# (tests/media_overlay.bats pins that set); a reader must not join it.
|
||||
! grep -q 'media-meta/view' "$unit" || return 1
|
||||
}
|
||||
|
||||
@test "audiobookshelf refuses to start against an unmounted array" {
|
||||
# Without the gate podman invents an empty bind source and the first scan
|
||||
# records an empty library as truth.
|
||||
unit="$REPO_ROOT/dankserver/audiobookshelf/quadlet/audiobookshelf.container"
|
||||
grep -q '^ExecStartPre=.*/wait-for-mount.sh /mnt/entropy$' "$unit" || return 1
|
||||
}
|
||||
|
||||
@test "audiobookshelf health check names a binary its image actually ships" {
|
||||
# The image is Alpine: wget yes, curl no. A curl HealthCmd reads the
|
||||
# container as unhealthy while it is serving perfectly.
|
||||
unit="$REPO_ROOT/dankserver/audiobookshelf/quadlet/audiobookshelf.container"
|
||||
grep -q '^HealthCmd=wget ' "$unit" || return 1
|
||||
! grep -q '^HealthCmd=curl' "$unit" || return 1
|
||||
grep -q '^PublishPort=8000:8000$' "$unit" || return 1
|
||||
}
|
||||
|
||||
@test "the audiobookshelf deployer creates both state roots before it starts" {
|
||||
body="$(sed -n '/^deploy_audiobookshelf()/,/^\}/p' "$REPO_ROOT/scripts/deploy-remote.sh")"
|
||||
mkdir_line="$(printf '%s\n' "$body" | grep -n 'mkdir -p' | head -1 | cut -d: -f1)"
|
||||
start_line="$(printf '%s\n' "$body" | grep -n 'systemctl --user restart' | head -1 | cut -d: -f1)"
|
||||
[ -n "$mkdir_line" ] && [ -n "$start_line" ] || return 1
|
||||
[ "$mkdir_line" -lt "$start_line" ] || return 1
|
||||
printf '%s\n' "$body" | grep -q 'audiobookshelf/config' || return 1
|
||||
printf '%s\n' "$body" | grep -q 'audiobookshelf/metadata' || return 1
|
||||
printf '%s\n' "$body" | grep -q 'wait_for_health audiobookshelf' || return 1
|
||||
}
|
||||
Reference in new issue
Block a user