diff --git a/app/server/index.js b/app/server/index.js index a66223baaf..b8112dff28 100644 --- a/app/server/index.js +++ b/app/server/index.js @@ -270,6 +270,17 @@ app.prepare().then(async () => { server.use('/print-pdf', await printPdf()); + // Endpoint /health sends a 500 status if there is an error connecting to the database or if the database is in recovery mode (result.rowAsArray === true) + server.get('/health', ({res}) => { + pgPool.query('SELECT pg_is_in_recovery();', [], (err, result) => { + if (err || result.rowAsArray) { + res.sendStatus(500); + } else { + res.sendStatus(200); + } + }); + }); + server.get('*', async (req, res) => { return handle(req, res); }); diff --git a/helm/cas-ciip-portal/templates/deploy.yaml b/helm/cas-ciip-portal/templates/deploy.yaml index 73a5a26634..fbae68a935 100644 --- a/helm/cas-ciip-portal/templates/deploy.yaml +++ b/helm/cas-ciip-portal/templates/deploy.yaml @@ -80,7 +80,7 @@ spec: readinessProbe: failureThreshold: 3 httpGet: - path: / + path: /health port: {{ .Values.port }} scheme: HTTP{{ if not .Values.route.insecure }}S{{ end }} periodSeconds: 10