7

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
  • 1,088
  • 18
  • 37
  • 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

12

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
  • 108,729
  • 24
  • 257
  • 242
  • 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
  • The documentation of Spring Boot is confusing: it says, to enable 'shutdown' endpoint one should only add `management.endpoint.shutdown.enabled=true` to the application.properties. https://docs.spring.io/spring-boot/docs/2.5.0/reference/htmlsingle/#using – Hermann Schwarz Apr 30 '22 at 08:01
  • Spring Boot makes a distinction between an endpoint being enabled and it being exposed through JMX or HTTP. This is [described in the documentation](https://docs.spring.io/spring-boot/docs/2.5.0/reference/htmlsingle/#actuator.endpoints). Setting `management.endpoint.shutdown.enabled=true` is sufficient to enable the endpoint. For security reasons, enabled endpoints are only exposed over JMX by default. If you want it to be accessible over HTTP, you need to [configure web exposure](https://docs.spring.io/spring-boot/docs/2.5.0/reference/htmlsingle/#actuator.endpoints.exposing). – Andy Wilkinson May 01 '22 at 10:59
10

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
  • 371
  • 4
  • 5
  • Thank you for additional info about the need of setting `management.endpoints.web.exposure.include=shutdown`. The documentation of Spring Boot is confusing: it says, to enable 'shutdown' endpoint one should only add `management.endpoint.shutdown.enabled=true` to the application.properties. https://docs.spring.io/spring-boot/docs/2.5.0/reference/htmlsingle/#using – Hermann Schwarz Apr 30 '22 at 08:03
6

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

Evan Knox Thomas
  • 592
  • 6
  • 12