Add container readiness checks and exclude local state from images
Adapted from MikaelKW/nodecast-tv-plus readiness and container context work. Co-authored-by: MikaelKW <87399352+MikaelKW@users.noreply.github.com>
This commit is contained in:
18
server/services/health.js
Normal file
18
server/services/health.js
Normal file
@ -0,0 +1,18 @@
|
||||
const database = require('../db');
|
||||
const { getDb } = require('../db/sqlite');
|
||||
|
||||
async function health(req, res) {
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
if (!req.app.locals.ready) return res.status(503).json({ status: 'unavailable' });
|
||||
try {
|
||||
await database.checkHealth();
|
||||
getDb().prepare('SELECT 1').get();
|
||||
// Readiness may change while the asynchronous JSON check is running.
|
||||
if (!req.app.locals.ready) return res.status(503).json({ status: 'unavailable' });
|
||||
res.json({ status: 'ok' });
|
||||
} catch {
|
||||
res.status(503).json({ status: 'unavailable' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = health;
|
||||
Reference in New Issue
Block a user