zoukankan      html  css  js  c++  java
  • springboot actuator shutdown正确的关闭操作

    今天整合ehcache时发现一个很重要的问题,就是程序关闭(硬关闭)之后,持久化到磁盘的缓存数据没能正确写入加载,问题还是硬关闭的问题,所以就使用actuator 进行监听

    <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    application.properties中添加(这里使用的是springboot2.x,所以management.endpoint替换了1.x的endpoints)

    #启用shutdown

    management.endpoint.shutdown.enabled=true

    重启之后(/actuator 查看添加的监听接口)发现是没有需要的(/shutdown)

    {
        "_links": {
            "self": {
                "href": "http://localhost:8082/actuator",
                "templated": false
            },
            "health": {
                "href": "http://localhost:8082/actuator/health",
                "templated": false
            },
            "info": {
                "href": "http://localhost:8082/actuator/info",
                "templated": false
            }
        }
    }

    application.properties中添加

    management.endpoints.web.exposure.include=*

    (/actuator/shutdown)正常返回

    {
        "message": "Shutting down, bye..."
    }

     修改默认(/actuator)前缀路径)application.properties中添加

    management.endpoints.web.base-path=/system/actuator
  • 相关阅读:
    file
    shell脚本的执行
    添加源,删除源
    lsattr, chattr
    umask
    od
    init
    sync
    wc
    history
  • 原文地址:https://www.cnblogs.com/skyLogin/p/9214575.html
Copyright © 2011-2022 走看看