6

I created hello world Spring Boot v2.0.0.M7 app, added actuator, enabled shutdown and it isn't working.

application.properties

server.port=8082
endpoint.shutdown.enabled=true
endpoint.shutdown.sensitive=false

health works fine

enter image description here

but not the shutdown

enter image description here

What am I doing wrong?

Community
  • 1
  • 1
ieXcept
  • 834
  • 13
  • 31
  • I might be wrong, but I think you have to POST to the shutdown endpoint. Likely a duplicate: https://stackoverflow.com/questions/45700355/using-the-spring-boot-actuator-to-shutdown-a-rest-server-safely – Marged Jan 10 '18 at 17:19
  • @Marged Does the official documentation mentioned this? How would I suppose to know it? https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/html/production-ready-endpoints.html – ieXcept Jan 10 '18 at 17:32
  • Like Andy confirmed: it is stated in the docs – Marged Jan 10 '18 at 21:04

3 Answers3

9

Endpoints have changed quite a bit in Spring Boot 2.0 and, as a result, your configuration is out of date. You need to enable the endpoint and also expose it over HTTP:

management.endpoints.web.expose=*
management.endpoint.shutdown.enabled=true

As already noted in the comments, and described in the Actuator HTTP API documentation, you also need to make a POST request so accessing the endpoint in your browser won't work. You can use something like curl on the command line instead:

$ curl -X POST localhost:8080/actuator/shutdown

You can learn more about changes in Spring Boot 2.0 by reading the release notes.

Andy Wilkinson
  • 85,432
  • 19
  • 215
  • 204
  • Thank you! I missed the fact that besides exposing the endpoint, one has to explicitly enable it, too! Otherwise one has a warning in the log (but I haven't paid enough attention to it and thus could not determine what I had been missing). – Igor Nov 25 '19 at 00:50
9

spring boot version : 2.0.1.RELEASE

pom.xml

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

application.properties

management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true

then, try

$ curl -X POST localhost:8080/actuator/shutdown
Jeen
  • 281
  • 3
  • 4
6

spring-boot 2.0 default
management.endpoints.web.exposure.include=info, health,
change to
management.endpoints.web.exposure.include=info, health, shutdown

Evan
  • 460
  • 4
  • 6