Reputation: 720
I have run into an issue where a load balancer that is calling the Spring Boot healthcheck endpoint to determine if app is up receives a status of UP from Spring Boot before the Spring App is actually UP.
Is there an easy way to delay the Actuator startup until after the web app has started?
Upvotes: 0
Views: 1058
Reputation: 415
You can listen to the application events in a custom health check implementation.
class MyHealthIndicator implements HealthIndicator, ApplicationListener<ApplicationStartedEvent> {
boolean ready = false;
public void onApplicationEvent(ApplicationStartedEvent event) {
ready = true;
}
}
But as commented above, you'll probably experience that the endpoint isn't avaliable until application has started anyway.
Upvotes: 1
Reputation: 14651
You actually have the option to configure special MVC healthcheck indicators.
Check this example: MVC Endpoint
@Component
public class EndpointsMvcEndpoint extends EndpointMvcAdapter {
private final EndpointsEndpoint delegate;
Upvotes: 0