feat(web): publish a public status page at /status
Checking whether the service is up required an account, so the answer lived where the people asking could not reach it. The page is rendered on the server with no script at all and refreshes through a meta tag: a status page that needs a working browser is useless at the moment it is read. Two rules follow from it being public. A repository the forge does not list as public keeps its environment visible but loses its name, and the banner always states the worst true thing — a failed deployment forbids the green headline even while the bot answers. WEB_PUBLIC_STATUS=false removes page and route together. /api/status gives the same in JSON, which is what a monitor should watch rather than /api/health — the latter only says the process is alive. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9acb523510
commit
a1e1de7734
11 files changed
+823
No files matched your search
@@ -12,6 +12,8 @@ import { broadcast, closeEventStreams, topicForPath } from './events.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendHtml, sendJson, sendStatic } from './http.js';
|
||||
import { createRouter } from './router.js';
|
||||
import { listPublished } from '../database/repositories/wiki-repository.js';
|
||||
import { renderStatus } from './services/status-render.js';
|
||||
import { statusSnapshot } from './services/status-service.js';
|
||||
import { pagePath } from './services/wiki-seed.js';
|
||||
import { renderIndex, renderNotFound, renderPage } from './services/wiki-render.js';
|
||||
import { ROOT_PAGES, seedWiki } from './services/wiki-seed.js';
|
||||
@@ -140,6 +142,25 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
return;
|
||||
}
|
||||
|
||||
// Same reasoning for the status page, with one addition: it is read when
|
||||
// something is wrong, which is the worst moment to need a working browser.
|
||||
// Turned off, it answers 404 rather than falling through to the dashboard
|
||||
// shell — « this address does not exist here » is the honest answer, and
|
||||
// a shell served at /status only looks like a broken status page.
|
||||
if (pathname.replace(/\/+$/, '') === '/status') {
|
||||
if (!env.web.publicStatus) {
|
||||
sendEmpty(response, 404);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sendHtml(response, 200, renderStatus(await statusSnapshot(context)));
|
||||
} catch (error) {
|
||||
log.error('Could not render the status page', error);
|
||||
sendHtml(response, 503, '<!doctype html><title>État indisponible</title><p>État indisponible.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const served = await sendStatic(response, publicDir, pathname, {
|
||||
fallback: 'index.html',
|
||||
request,
|
||||
|
||||
Reference in new issue
Block a user