Add 10-second test health logger and /_cron/tick endpoint

This commit is contained in:
Noah AI
2026-07-02 11:12:19 +00:00
parent cd11eac976
commit 5a5d190dec

View File

@@ -18,18 +18,18 @@ const apiRoot = config.apiPrefix || '/';
app.use(apiRoot, createHealthRouter(config)); app.use(apiRoot, createHealthRouter(config));
app.use(apiRoot, createTodosRouter(config, db)); app.use(apiRoot, createTodosRouter(config, db));
// 1. Background 10-second health check logger
// 10-second health check logger
setInterval(() => { setInterval(() => {
console.log('[Health Check] Sandbox is healthy at ' + new Date().toISOString()); console.log('[Health Check] Sandbox is healthy at ' + new Date().toISOString());
}, 10000); }, 10000);
// 2. Cloud Run Cron Tick endpoint (No-op to wake up event loop)
app.post('/_cron/tick', (req, res) => { app.post('/_cron/tick', (req, res) => {
const authHeader = req.headers.authorization; const authHeader = req.headers.authorization;
if (!authHeader || authHeader !== 'Bearer ' + process.env.CRON_TOKEN) { if (!authHeader || authHeader !== 'Bearer ' + process.env.CRON_TOKEN) {
return res.status(401).json({ success: false, error: 'Unauthorized' }); return res.status(401).json({ success: false, error: 'Unauthorized' });
} }
console.log('[Tick] Cloud Run cron tick triggered.'); console.log('[Tick] Heartbeat received. Waking up event loop.');
res.status(200).json({ success: true }); res.status(200).json({ success: true });
}); });