Spring引导管理员是一个很好的工具,可以使我的Spring引导应用程序(在我的情况下是Web服务器)的运行状况和指标可用。我遵循reference guide,最终可能会运行它,但有一个例外:服务器似乎无法识别客户端是否崩溃/崩溃。Spring引导管理员:应用程序崩溃后,应用程序状态仍为“UP”
对于测试,我目前使用单独的应用程序,都运行在同一主机上。在最终版本中,我打算让多个客户端(在单独的IP地址上运行)向在单独的IP上运行的单个服务器注册)。
服务器(单独的弹簧引导工程)
的pom.xml
...
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
...
application.properties:
server.port=8081
MyMain:
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class MyMain {
public static void main(String[] args) {
SpringApplication.run(MyMain.class, args);
}
}
客户(要监视我的Web应用程序):
的pom.xml:
...
<!-- SPRING BOOT ADMIN (CLIENT) -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
...
application.properties:
server.port=8080
spring.boot.admin.url=http://localhost:8081
spring.boot.admin.client.management-url=http://localhost:8081
spring.boot.admin.client.service-url=http://localhost:8080
spring.boot.admin.client.name=my-rest-app
通过此设置,我可以连接到http://localhost:8080以获取我的网络应用或http://localhost:8081以查看管理员/监控UI。状态显示UP,我可以浏览MEM /堆/痕迹/ ...
现在的问题是,如果我杀了网络应用程序状态保持UP。
- 从描述我会假设服务器属性
spring.boot.admin.monitor.period
正在检查客户端应用程序的状态每10秒。 - 或者,我是否需要此通知功能?
,您在IDE中运行你的启动客户更这里 - ?如果是的话,那么请尝试从终端运行spring boot client和admin,我在我的情况下面临同样的问题。 – Harshil