mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 16:35:23 +00:00
Don't throw an error when getting an unhealthy state
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
8fdd5a4e65
commit
6b827a3f57
@ -103,11 +103,17 @@ export class SupervisorAPI {
|
|||||||
this.api.use(expressLogger);
|
this.api.use(expressLogger);
|
||||||
|
|
||||||
this.api.get('/v1/healthy', async (_req, res) => {
|
this.api.get('/v1/healthy', async (_req, res) => {
|
||||||
const healths = await Promise.all(this.healthchecks.map(fn => fn()));
|
try {
|
||||||
if (!_.every(healths)) {
|
const healths = await Promise.all(this.healthchecks.map(fn => fn()));
|
||||||
throw new Error('Unhealthy');
|
if (!_.every(healths)) {
|
||||||
|
log.error('Healthcheck failed');
|
||||||
|
return res.status(500).send('Unhealthy');
|
||||||
|
}
|
||||||
|
return res.sendStatus(200);
|
||||||
|
} catch (_e) {
|
||||||
|
log.error('Healthcheck failed');
|
||||||
|
return res.status(500).send('Unhealthy');
|
||||||
}
|
}
|
||||||
return res.sendStatus(200);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.api.get('/ping', (_req, res) => res.send('OK'));
|
this.api.get('/ping', (_req, res) => res.send('OK'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user