1

我正在研究为通过容器编排运行的 nodejs 微服务设置运行状况检查机制。从 nodejs/express 的角度来看,确保服务确实在给定容器的给定端口上运行的最佳实践是什么?例如。健康检查中间件或特定的 nodejs 库,使用单独的服务端口等。

4

1 回答 1

2

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

于 2018-10-01T08:15:55.163 回答