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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM