简体   繁体   English

Tomcat中的Web应用程序部署状态

[英]Web Application deployment status in tomcat

I have java web application (.war) and deployed into application server (tomcat or any app server). 我有Java Web应用程序(.war),并已部署到应用程序服务器(tomcat或任何应用程序服务器)中。 I need to write a REST API which returns health check of that application or status of deployment of that application in server. 我需要编写一个REST API,该API返回该应用程序的运行状况检查或该应用程序在服务器中的部署状态。

So my requirement something like, 所以我的要求是

http://<host>:<port>/myapp/healthcheck

response : {"status":"UP"}

How I can implement this feature. 我如何实现此功能。 I have tried JavaMelody but I have not seen status or health check API in JavaMelody which return application deployment status. 我已经尝试过JavaMelody,但没有在JavaMelody中看到状态或运行状况检查API,它们返回应用程序部署状态。

You might like wildfly's health check . 您可能需要Wildfly的健康检查 That allows you to create JAXRS endpoints annotated with @Health and returning status UP or DOWN depending on the app state. 这样,您就可以创建带有@Health注释的JAXRS端点,并根据应用程序状态返回状态UP或DOWN。

@GET
@Path("/health")
@Health
public HealthStatus checkHealth() {
   return isMyAppOK() ? HealthStatus.up() : HealthStatus.down();
}

Other option can be spring boot actuator which exposes /health endpoint to your spring boot application. 其他选项可以是Spring Boot执行器 ,它将/ health端点公开给Spring Boot应用程序。

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

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