mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-29 18:18:52 +00:00
Merge pull request #1230 from balena-io/fix-unhandled-health-rejection
Don't throw an error when getting an unhealthy state
This commit is contained in:
commit
20e339317e
@ -103,11 +103,17 @@ export class SupervisorAPI {
|
||||
this.api.use(expressLogger);
|
||||
|
||||
this.api.get('/v1/healthy', async (_req, res) => {
|
||||
const healths = await Promise.all(this.healthchecks.map(fn => fn()));
|
||||
if (!_.every(healths)) {
|
||||
throw new Error('Unhealthy');
|
||||
try {
|
||||
const healths = await Promise.all(this.healthchecks.map(fn => fn()));
|
||||
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'));
|
||||
|
Loading…
Reference in New Issue
Block a user