feat: log structured reconnect diagnostics for kiosk display layers (#2)
Build Ground Station / build (push) Successful in 1m2s

This commit was merged in pull request #13.
This commit is contained in:
2026-10-02 10:23:28 +02:00
parent 41552b4797
commit 2ced44b47b
4 changed files with 314 additions and 4 deletions
+25 -1
View File
@@ -44,6 +44,28 @@ func buildTarget(name string) ([]display.Layer, error) {
}
}
// wireDiagnostics gives every layer the shared structured reconnect hook so
// each layer reports its own reconnect boundaries, identified by target and
// layer name.
func wireDiagnostics(target string, layers []display.Layer) {
for i := range layers {
layers[i].Options = display.Options{
Target: target,
Layer: layers[i].Name,
Diagnostic: func(d display.Diagnostic) {
log.Printf("display reconnect: %s", formatDiagnostic(d))
},
}
}
}
// formatDiagnostic renders one reconnect diagnostic as key=value fields so
// reconnects stay greppable and machine-parseable in the journal.
func formatDiagnostic(d display.Diagnostic) string {
return fmt.Sprintf("target=%s layer=%s event=%s error=%q retry_delay=%s",
d.Target, d.Layer, d.Event, d.Err, d.RetryDelay)
}
func main() {
target := flag.String("target", "x11", "display target: x11 (Viture) today; mipi planned")
flag.Parse()
@@ -52,11 +74,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
wireDiagnostics(*target, layers)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
// Temporary X11 unavailability never exits this process; every layer
// keeps retrying internally until the context is cancelled.
// keeps retrying internally until the context is cancelled, reporting
// each reconnect boundary through the structured diagnostic hook.
display.RunLayers(ctx, layers)
}