简体   繁体   English

Node.js应用程序运行状况检查最佳实践

[英]Nodejs application healthcheck best practice

I'm looking into setting up a healthcheck mechanism for nodejs microservices running via container orchestrations. 我正在研究为通过容器编排运行的nodejs微服务建立运行状况检查机制。 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? 从nodejs / express的角度来看,什么是确保服务确实在给定容器上的给定端口上运行的最佳实践? Eg. 例如。 A healthcheck middleware or particular nodejs library, using a separate service port etc. 使用单独的服务端口等的运行状况检查中间件或特定的nodejs库。

In order to implement healthcheck in nodejs, use the following 为了在nodejs中实现运行状况检查,请使用以下命令

use express-healthcheck as a dependency in your nodejs project in your app.js or equivalent code, use the following line 使用express-healthcheck作为app.js或等效代码中的nodejs项目中的依赖项,请使用以下行

app.use('/healthcheck', require('express-healthcheck')()); app.use('/ healthcheck',require('express-healthcheck')()); if your app is up your response will be like { "uptime":23.09 } 如果您的应用启动了,您的响应将像{“正常运行时间”:23.09}

also it returns a status code of 200 Hope this helps 同时返回状态码200希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM