2/28/18

HTTP endpoint to shut down a spring boot

Maven quick example for maven user to configure HTTP endpoint to shut down a spring boot web app using spring-boot-starter-actuator so that you can copy and paste:
1. Maven pom.xml:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2. application.properties:
#NEED auth  protected 
endpoints.shutdown.sensitive=true

#Enable shutdown endpoint
endpoints.shutdown.enabled=true
All endpoints are listed here:
3.Send a post method to shutdown the app:
curl -X POST localhost:port/shutdown

Security Note:

if you need the shutdown method auth protected, you may also need
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>

management.security.enabled=true
security.user.name=admin
security.user.password=secret
management.security.roles=SUPERUSER

No comments: