feat: extend k3s artifact consumers

This commit is contained in:
Codex
2026-05-20 02:58:41 +00:00
parent 15a1a8b21a
commit 595de3d320
28 changed files with 1003 additions and 76 deletions
@@ -89,6 +89,10 @@ const rootRealPath = resolveRealWorkspaceRoot(workspaceRoot);
const maxFiles = envNumber("MDTODO_MAX_FILES", 250);
const recentLogs: JsonRecord[] = [];
const logFile = envString("LOG_FILE", envString("MDTODO_LOG_FILE", "/var/log/unidesk/mdtodo.jsonl"));
const deployServiceId = envString("UNIDESK_DEPLOY_SERVICE_ID", "mdtodo");
const deployRepo = envString("UNIDESK_DEPLOY_REPO", "");
const deployCommit = envString("UNIDESK_DEPLOY_COMMIT", "");
const deployRequestedCommit = envString("UNIDESK_DEPLOY_REQUESTED_COMMIT", deployCommit);
const logWriter = logFile
? createHourlyJsonlWriter({
baseLogFile: logFile,
@@ -592,6 +596,12 @@ function healthSnapshot(): { body: JsonRecord; status: number } {
ok: healthy,
service: "mdtodo",
startedAt,
deploy: {
serviceId: deployServiceId,
repo: deployRepo,
commit: deployCommit,
requestedCommit: deployRequestedCommit,
},
rootDir: workspaceRoot,
rootExists,
writable,
@@ -622,7 +632,17 @@ async function route(req: Request): Promise<Response> {
const health = healthSnapshot();
return jsonResponse(health.body, health.status);
}
if (url.pathname === "/live") return jsonResponse({ ok: true, service: "mdtodo", startedAt });
if (url.pathname === "/live") return jsonResponse({
ok: true,
service: "mdtodo",
startedAt,
deploy: {
serviceId: deployServiceId,
repo: deployRepo,
commit: deployCommit,
requestedCommit: deployRequestedCommit,
},
});
if (url.pathname === "/logs" && req.method === "GET") return jsonResponse({ ok: true, logs: recentLogs.slice(-100) });
if (url.pathname === "/api/files" && req.method === "GET") return jsonResponse({ ok: true, rootDir: workspaceRoot, files: listTodoFiles() });
if (url.pathname === "/api/content" && req.method === "GET") {