简体   繁体   中英

checking whether spring boot application is running or not

I've created a spring boot project and deployed it on a vm. I've added a command in local.rc that starts the spring boot application on reboot. I want to check whether the command got executed and the application is running. How do I do that?

There are two ways

  1. On system level - you can run your project as a service, which is documented in the Official documentation - Deployments . Then you can query the application status service myapp status .

  2. On application level - include Spring Boot Actuator in your app and use the Actuator endpoints such as /actuator/health as per Official documentation - Production Ready Endpoints . These endpoints can be exposed via HTTP or JMX .

Note: prior to spring boot 2.0 the actuator endpoint is /health

If it's a web project, it makes sense to include spring-boot-actuator (just add a dependency in maven and start the microservice).

In this case, it will automatically expose the following endpoint (for example, its actually can be flexibly set up):

http://<HOST>:<PORT>/health

Just issue an HTTP GET request, and if you get 200 - it's up and running.

If using an actuator is not an option (although it should be really addressed as a first bet), then you can merely telnet to http://<HOST>:<PORT>

The ratio behind this is that that PORT is exposed and ready to "listen" to external connections only after the application context is really started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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