Multi-instance terminal UI dashboard for monitoring all ServeReport
processes simultaneously. Uses MQTT heartbeats for live instance tracking
and a slow DB poll for static configuration data.
ReportTUI subscribes to MQTT topic axion/+/heartbeat/report/+ to receive
retained heartbeats from every running ServeReport instance. Each instance
publishes a heartbeat every TuiConstants.HEARTBEAT_INTERVAL_SECS (15 s).
An instance is shown as stale after TuiConstants.HEARTBEAT_STALE_SECS (45 s).
The def_report table is polled separately every TuiConstants.CONFIG_POLL_SECS
(60 s) — slow enough to avoid DB pressure when many TUI processes run concurrently.
__init__(self)Initialises theme, console, layout, and internal state. No port parameter —
all instance data arrives via MQTT.
start(self) / stop(self)start() calls _start_mqtt(), renders the initial layout, and launches the
background update thread. stop() signals the stop event, disconnects the
MQTT client, and tears down the Live context.
_start_mqtt(self) (internal)Connects a paho MQTT client, subscribes to the heartbeat wildcard, and updates
self.instances[instance_id] on each message.
_poll_config(self) (internal)Runs every CONFIG_POLL_SECS. Queries def_report WHERE Package = ? for
total count and a (ReportCode, ReportType, Description) listing.
| Panel | Content |
|---|---|
| Header | Heartbeat, package, Instances: N/M, clock, uptime |
| Sidebar | Package, active/total counts, DB status, report count, TUI uptime |
| Instances | Table of all known instances — instance ID, package, uptime, PID, status |
| Reports | Table of report definitions — code, type, description |
| Log | Scrolling log |
| Footer | Last config poll timestamp |
python ServeReport.py tui
Press Ctrl+C to exit.