Skip to content
Snippets Groups Projects
Commit 43ae0c65 authored by Viktor Vorobev's avatar Viktor Vorobev
Browse files

Merged in NRRPLT-8944-health-endpoint (pull request #9)

[NRRPLT-8944] Adding /health endpoint as in NRP3

* [NRRPLT-8944] Adding /health endpoint as in NRP3


Approved-by: Ugo Albanese
parent 70e27a53
Branches
No related tags found
No related merge requests found
......@@ -791,6 +791,25 @@ app.post('/checkupdate', async (req, res) => {
res.send({ version });
});
/**
* Checks the number of available backends.
* If there are available backends, responds with JSON {service: "healthy"}
* If there are no backends, responds with JSON {service: "unavailable"}
* The response status 200 confirms the unavailability of the proxy itself
*/
app.get('/health', (req, res, next) => {
proxyRequestHandler
.getAvailableServers()
.then(servers => {
if (servers.length > 0) {
res.send({service: 'healthy'});
} else {
res.send({service: 'unavailable'});
}
})
.catch(next);
});
configurationManager.configuration.then(null, null, conf =>
proxyRequestHandler.reloadConfiguration(conf)
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment