()
| 56 | } |
| 57 | |
| 58 | const getRelayUptimeSeconds = async (): Promise<number | null> => { |
| 59 | const idResult = await runCommandWithOutput('docker', ['compose', 'ps', '-q', 'nostream'], { timeoutMs: 1000 }) |
| 60 | if (!idResult.ok || idResult.code !== 0) { |
| 61 | return null |
| 62 | } |
| 63 | |
| 64 | const containerId = idResult.stdout.trim() |
| 65 | if (!containerId) { |
| 66 | return null |
| 67 | } |
| 68 | |
| 69 | const startedAtResult = await runCommandWithOutput('docker', ['inspect', '--format', '{{.State.StartedAt}}', containerId], { |
| 70 | timeoutMs: 1000, |
| 71 | }) |
| 72 | if (!startedAtResult.ok || startedAtResult.code !== 0) { |
| 73 | return null |
| 74 | } |
| 75 | |
| 76 | const startedAtRaw = startedAtResult.stdout.trim() |
| 77 | const startedAtMs = Date.parse(startedAtRaw) |
| 78 | if (!Number.isFinite(startedAtMs)) { |
| 79 | return null |
| 80 | } |
| 81 | |
| 82 | const seconds = Math.max(0, Math.floor((Date.now() - startedAtMs) / 1000)) |
| 83 | return seconds |
| 84 | } |
| 85 | |
| 86 | const formatUptime = (uptimeSeconds: number | null): string => { |
| 87 | if (uptimeSeconds === null) { |
no test coverage detected