feat(daemon): report host uptime, not only the daemon's process age
The status tile labelled "uptime" showed the age of the daemon *process* (`/info.uptimeMs`), and `/info` was fetched once with a 30 s staleTime and no refetch interval, so the figure also froze: on a box five days up, a `pi2 update` restart made the tile read "3m" and it never moved again. `os.uptime()` is now sampled with the other host figures and served as `system.hostUptimeSec` — which the 3 s `/resources` poll already refreshes — plus an additive `/info.hostUptimeMs`. The tile renders it through a `LiveUptime` label that anchors the reported snapshot once and ticks locally, so the counter advances without a refetch and cannot rewind on a re-render. The daemon's own process age stays in the server card, relabelled `status.daemonUptime`, next to the `pid`/`daemonId` that give it meaning.
This commit is contained in:
1 parent
01fd7b9922
commit
2f2f1bb518
16 files changed
+204
-10
No files matched your search
@@ -64,6 +64,8 @@ const resourcesBody = {
|
||||
physicalMemoryBytes: 2048 * 1024 * 1024,
|
||||
system: {
|
||||
sampledAt: Date.now(),
|
||||
// Host uptime, deliberately different from the daemon's own age in `infoBody`.
|
||||
hostUptimeSec: 3 * 86_400,
|
||||
cpuPercent: 37,
|
||||
cpuCores: 8,
|
||||
loadAvg: [1.23, 0.98, 0.75],
|
||||
@@ -264,7 +266,8 @@ describe("StatusPage", () => {
|
||||
expect(document.querySelector('.status-tile[data-res="disk"] .tile__meta')).toHaveTextContent("/var/lib/pi2");
|
||||
expect(document.querySelector('.status-tile[data-res="cpu"] .tile__meta')).toHaveTextContent("8");
|
||||
expect(document.querySelector('.status-tile[data-res="cpu"] .tile__meta')).toHaveTextContent("1.23");
|
||||
expect(document.querySelector('.status-tile[data-res="uptime"] .tile__value')).toHaveTextContent("2h 5m");
|
||||
// The tile shows the host, not the daemon process (`/info.uptimeMs` is 2h 5m).
|
||||
expect(document.querySelector('.status-tile[data-res="uptime"] .tile__value')).toHaveTextContent("3d 0h 0m");
|
||||
|
||||
const counts = document.querySelector(".status-counts");
|
||||
expect(counts).not.toBeNull();
|
||||
|
||||
Reference in new issue
Block a user