L P
L P

Reputation: 1846

Nodejs application healthcheck best practice

I'm looking into setting up a healthcheck mechanism for nodejs microservices running via container orchestrations. From a nodejs/express point of view, what is considered best practice to ensure that the service is indeed running on a given port on a given container? Eg. A healthcheck middleware or particular nodejs library, using a separate service port etc.

Upvotes: 1

Views: 5754

Answers (1)

Mayukh Basu
Mayukh Basu

Reputation: 21

In order to implement healthcheck in nodejs, use the following

use express-healthcheck as a dependency in your nodejs project in your app.js or equivalent code, use the following line

app.use('/healthcheck', require('express-healthcheck')()); if your app is up your response will be like { "uptime":23.09 }

also it returns a status code of 200 Hope this helps

Upvotes: 2

Related Questions