【问题标题】:Spring-boot-admin: App status remains "UP" after app crashesSpring-boot-admin:应用程序崩溃后应用程序状态保持“UP”
【发布时间】:2017-01-29 15:37:49
【问题描述】:

Spring boot admin 是一个很棒的工具,可以让我的 Spring Boot 应用程序(在我的例子中是一个 Web 服务器)的运行状况和指标可用。我已经关注reference guide,终于可以让它运行了,不过有一个例外:服务器似乎无法识别客户端是否崩溃/宕机。

为了进行测试,我目前使用单独的应用程序,它们都在同一主机上运行。在最终版本中,我计划让多个客户端(运行在不同的 IP 地址上)向运行在其独立 IP 上的单个服务器注册)。

服务器(单独的 Spring Boot 项目)

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

我的主目录:

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class MyMain {
    public static void main(String[] args) {
        SpringApplication.run(MyMain.class, args);
    }
}

客户端(我的 WebApp 被监控):

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/heap/traces/...

现在的问题是,如果我终止网络应用程序,状态仍然是 UP。

  1. 根据描述,我假设服务器属性 spring.boot.admin.monitor.period 每 10 秒检查一次客户端应用程序的状态。
  2. 或者,我需要通知功能吗?

【问题讨论】:

  • 您是否从 IDE 运行您的引导客户端?如果是,那么请尝试从终端运行 spring boot 客户端和管理员,我遇到了同样的问题。

标签: monitoring spring-boot-actuator


【解决方案1】:

尝试从项目目录通过命令行运行应用程序 -

mvn spring-boot:run

【讨论】:

    【解决方案2】:

    这很简单。

    spring.boot.admin.auto-deregistration=true 
    

    在你的 application.properties 中设置它。

    请记住,这仅在您的应用程序正常终止或使用 SIGTERM (kill -15 PID) 时有效。

    如果您终止应用程序,应用程序不会自行注销,因为上下文未正确关闭。

    在此处查看更多信息-https://codecentric.github.io/spring-boot-admin/1.4.3/#spring-boot-admin-client

    【讨论】:

      猜你喜欢
      • 2020-05-01
      • 2018-10-08
      • 2023-03-03
      • 1970-01-01
      • 2017-04-04
      • 2017-03-14
      • 1970-01-01
      • 1970-01-01
      • 2018-09-16
      相关资源
      最近更新 更多