Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
A preview deploys while the Pi is offline: GET /healthz answers 200 from the relay alone, and forge.json's health points at it #153
smith/arm:smith/120-a-preview-deploys-while-the-pi-is-offlin → main 2 commits fork
3 files
changed +17
−1
Software/so101/src/relay.test.ts +14
| @@ -241,6 +241,20 @@ describe("relay", () => { | ||
| 241 | 241 | expect(await source(base)).toStartWith("simulated: offline, "); |
| 242 | 242 | }); |
| 243 | 243 | |
| 244 | test("/healthz is 200 from the relay alone while the arm refuses and /status is 503", async () => { | |
| 245 | hang = createTcpServer(); | |
| 246 | const port = await listening(hang); | |
| 247 | await new Promise((done) => hang!.close(done)); // nothing listens there now: connections are refused | |
| 248 | relay = await startRelay({ port: 0, simulation: simBase, remote: remoteAt(port), link: FAST }); | |
| 249 | const base = `http://127.0.0.1:${relay.port}`; | |
| 250 | const h = await fetch(`${base}/healthz`); | |
| 251 | expect(h.status).toBe(200); | |
| 252 | expect(await h.json()).toEqual({ ok: true }); | |
| 253 | expect(h.headers.get("cache-control")).toBe("no-store"); | |
| 254 | expect(h.headers.get("x-content-type-options")).toBe("nosniff"); | |
| 255 | expect((await fetch(`${base}/status`)).status).toBe(503); | |
| 256 | }); | |
| 257 | ||
| 244 | 258 | test("the forge's egress proxy cannot reach the arm: its reason is the one the page and /status give", async () => { |
| 245 | 259 | camera = createServer((_req, res) => res.writeHead(502, { "content-type": "text/plain", "x-forge-egress": "refused" }).end("100.89.95.68:8101 did not answer\n")); |
| 246 | 260 | relay = await startRelay({ port: 0, simulation: simBase, remote: remoteAt(await listening(camera)) }); |
Software/so101/src/relay.ts +1
| @@ -626,6 +626,7 @@ export async function startRelay(options: RelayOptions): Promise<RunningRelay> { | ||
| 626 | 626 | if (refused) return json(res, refused.status, { error: refused.error }); |
| 627 | 627 | by = who!.name; |
| 628 | 628 | } |
| 629 | if (req.method === "GET" && url.pathname === "/healthz") return json(res, 200, { ok: true }); // the relay alone: never the arm, the camera or the simulation | |
| 629 | 630 | if (req.method === "GET" && url.pathname === "/link") return json(res, 200, link()); |
| 630 | 631 | if (req.method === "GET" && url.pathname === "/status") return await status(res, path); |
| 631 | 632 |
forge.json +2 −1
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | "run": "bun run Software/so101/bench/fake-serve.ts", |
| 5 | 5 | "tty": "bun run Software/so101/src/tty.ts", |
| 6 | 6 | "test": "bun --cwd Software/so101 test", |
| 7 | "health": "/", | |
| 7 | "health": "/healthz", | |
| 8 | 8 | "limits": { |
| 9 | 9 | "cpus": 6, |
| 10 | 10 | "memory": 6144 |
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | "100.89.95.68:8101" |
| 17 | 17 | ], |
| 18 | 18 | "check": { |
| 19 | "run": "bun --cwd Software/so101 run typecheck && bun --cwd Software/so101 test", | |
| 19 | 20 | "limits": { |
| 20 | 21 | "cpus": 6, |
| 21 | 22 | "memory": 6144 |
new above
offline