From 8d0fb8e157aed66e89c592d23667d2a2028fbd89 Mon Sep 17 00:00:00 2001 From: Paul Nothaft Date: Mon, 27 Apr 2026 15:30:03 +0200 Subject: [PATCH] chore: expose pid + uptime on /health for crash-detection monitors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `pid` and `uptime` fields to the /health response so external monitors (and the local E2E watchdog) can detect a silent process restart between two checks — e.g. an unhandled rejection that crashes Node and Docker quietly relaunches the container. Also adds .gitignore patterns for a local-only E2E suite that lives in tests/e2e/local/ on individual machines and is never pushed. --- .gitignore | 6 ++++++ backend/server.js | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 931739a7..a49a1d81 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,12 @@ backup/ # Local artifacts from browser tooling .playwright-mcp/ +# Local-only E2E suite (never pushed; runs as pre-push gate on this machine) +tests/e2e/local/ +playwright-local-results/ +e2e-test.log +scripts/e2e-local.sh + # Local SQLite files in backend backend/*.sqlite* backend/*.db diff --git a/backend/server.js b/backend/server.js index 5bd6f1b4..ba62cc4a 100644 --- a/backend/server.js +++ b/backend/server.js @@ -486,21 +486,24 @@ app.get('/robots.txt', async (req, res) => { } }); -// Health check endpoint +// Health check endpoint. `pid` + `uptime` let monitors (and the local E2E +// watchdog) detect a silent process restart between two checks. app.get('/health', async (req, res) => { try { - // Check database connectivity await db.raw('SELECT 1'); - res.json({ status: 'ok', - timestamp: new Date().toISOString() + timestamp: new Date().toISOString(), + pid: process.pid, + uptime: process.uptime() }); } catch (error) { logger.error('Health check failed:', error); res.status(503).json({ status: 'error', - timestamp: new Date().toISOString() + timestamp: new Date().toISOString(), + pid: process.pid, + uptime: process.uptime() }); } });