same dek staging-dev

This commit is contained in:
Josh 2025-08-08 19:25:45 +00:00
parent c266a9d3b3
commit 1d82a6077c
4 changed files with 42 additions and 30 deletions

2
.env
View File

@ -2,7 +2,7 @@ CORS_ALLOWED_ORIGINS=https://dev1.aptivaai.com,http://34.16.120.118:3000,http://
SERVER1_PORT=5000 SERVER1_PORT=5000
SERVER2_PORT=5001 SERVER2_PORT=5001
SERVER3_PORT=5002 SERVER3_PORT=5002
IMG_TAG=a9421f5-202508081846 IMG_TAG=6a4d533-202508081922
ENV_NAME=dev ENV_NAME=dev
PROJECT=aptivaai-dev PROJECT=aptivaai-dev

View File

@ -100,15 +100,19 @@ app.use(
}) })
); );
app.get('/healthz', async (req, res) => { // LIVENESS: process is up; no external deps
app.get('/healthz', (req, res) => res.type('text').send('OK'));
// READINESS: KMS/DEK/DB are correct
app.get('/readyz', async (req, res) => {
try { try {
await verifyCanary(pool); // throws if bad await verifyCanary(pool); // throws if bad
return res.type('text').send('OK'); // cheap 200 OK return res.type('text').send('READY');
} catch (e) { } catch (e) {
console.error('[HEALTHZ]', e.message); console.error('[READYZ]', e.message);
return res.status(500).type('text').send('FAIL'); return res.status(503).type('text').send('NOT_READY');
} }
}); });
// Enable CORS with dynamic origin checking // Enable CORS with dynamic origin checking
app.use( app.use(

View File

@ -67,16 +67,20 @@ await verifyCanary(pool);
const app = express(); const app = express();
const PORT = process.env.SERVER2_PORT || 5001; const PORT = process.env.SERVER2_PORT || 5001;
// at top of backend/server.js (do once per server codebase) // LIVENESS: process is up; no external deps
app.get('/healthz', async (req, res) => { app.get('/healthz', (req, res) => res.type('text').send('OK'));
// READINESS: KMS/DEK/DB are correct
app.get('/readyz', async (req, res) => {
try { try {
await verifyCanary(pool); // << just pass the pool await verifyCanary(pool); // throws if bad
return res.type('text').send('OK'); return res.type('text').send('READY');
} catch (e) { } catch (e) {
console.error('[HEALTHZ]', e.message); console.error('[READYZ]', e.message);
return res.status(500).type('text').send('FAIL'); return res.status(503).type('text').send('NOT_READY');
} }
}); });
/************************************************** /**************************************************
* DB connections * DB connections

View File

@ -71,16 +71,20 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2024-04-10', apiVersion: '2024-04-10',
}); });
// at top of backend/server.js (do once per server codebase) // LIVENESS: process is up; no external deps
app.get('/healthz', async (req, res) => { app.get('/healthz', (req, res) => res.type('text').send('OK'));
// READINESS: KMS/DEK/DB are correct
app.get('/readyz', async (req, res) => {
try { try {
await verifyCanary(pool); // << just pass the pool await verifyCanary(pool); // throws if bad
return res.type('text').send('OK'); return res.type('text').send('READY');
} catch (e) { } catch (e) {
console.error('[HEALTHZ]', e.message); console.error('[READYZ]', e.message);
return res.status(500).type('text').send('FAIL'); return res.status(503).type('text').send('NOT_READY');
} }
}); });
function internalFetch(req, urlPath, opts = {}) { function internalFetch(req, urlPath, opts = {}) {
return fetch(`${API_BASE}${urlPath}`, { return fetch(`${API_BASE}${urlPath}`, {