the oneshot+timer produced 8367 journal lines a day of systemd start/stop noise. now Type=notify with an internal ticker, logging transitions only. hardware sits behind sensor.Sensor; internal/monitor is pure, so the shutdown state machine is tested without a pi. four guards, each tested, because a false poweroff of a box with no physical access is worse than a missed one: - a failed read resets the arming window rather than pausing it - voltage must actually fall across the window, else it is a stuck sensor. this is the only defence against the ac line reading 0 while mains is connected, so it is load-bearing - a settle period stops a restart loop acting on early readings - flapping ac cannot accumulate verified on hardware 2026-08-09: after poweroff on battery the x1208 starts the pi again when mains returns, with no button press. that was the risk that could have made this feature unsafe. a failed tick rewrites the previous sample with sensor_healthy 0 and the failure counter, so last_update still freezes for the staleness alert while the failure stays visible. module path moved to git.mial.net. debian units and the compose overlay deleted; deployment lives in the infra repo.
41 lines
948 B
Makefile
41 lines
948 B
Makefile
# x1208-exporter — Geekworm X1208 UPS HAT exporter
|
|
#
|
|
# Deployment lives in the rpi.mial.net repo. There are no deploy recipes here.
|
|
|
|
default:
|
|
@just --list
|
|
|
|
# Compile everything
|
|
build:
|
|
go build ./...
|
|
|
|
# Run the test suite (all pure packages; the hardware packages need a Pi)
|
|
test:
|
|
go test ./...
|
|
|
|
test-verbose:
|
|
go test -v ./...
|
|
|
|
# Static checks
|
|
lint:
|
|
go vet ./...
|
|
gofmt -l .
|
|
|
|
fmt:
|
|
gofmt -w .
|
|
|
|
# Build the Nix package exactly as the Pi will
|
|
nix-build:
|
|
nix build .#x1208-exporter
|
|
|
|
# Run the daemon against a scripted sensor. Touches no hardware and powers
|
|
# nothing off — the shutdown command is replaced with an echo.
|
|
run-fake out="/tmp/x1208.prom":
|
|
go run . -fake -interval 1s -out {{ out }} \
|
|
-shutdown -shutdown-settle-ticks 2 -shutdown-samples 3 \
|
|
-shutdown-cmd "/usr/bin/env echo POWEROFF-WOULD-RUN"
|
|
|
|
# Print the metrics the fake run produced
|
|
show out="/tmp/x1208.prom":
|
|
@cat {{ out }}
|