问题描述
我有一个Spring Boot(2.3.3)应用程序,该应用程序已部署在PCF上,并且正在运行5个实例。
为了监视此应用程序的运行状况,我在执行/覆盖执行器程序包的ReactiveHealthIndicator的位置添加了自定义运行状况指示器。 health()方法调用会话服务以告知实例在经过一定次数后是启动还是关闭。
问题在于,即使一个实例发生故障,PCF运行状况检查也会关闭所有实例并重新启动。
如何确保PCF运行状况检查仅重新启动那些已关闭的实例,而不是所有实例。
我的自定义健康指标:
@Component @Slf4j @ConditionalOnProperty(
value = "app.custom.health.enabled",havingValue = "true",matchIfMissing = true)
public class MyCustomHealthIndicator implements ReactiveHealthIndicator {
private MyAsyncSessionHealthCheck myAsyncSessionHealthCheck;
public MyCustomHealthIndicator(MyAsyncSessionHealthCheck myAsyncSessionHealthCheck) {
this.myAsyncSessionHealthCheck = myAsyncSessionHealthCheck;
log.info("Using Custom health indicator.");
}
@Override
public Mono<Health> health() {
Health health = Health.up().build();
// Fire and forget async health check on session
myAsyncSessionHealthCheck.checkSessionHealth();
// Check counter and fail if greater than max
if (myAsyncSessionHealthCheck.checkForSessionFailure()) {
log.error("Health Down because of session service check failed.");
health = Health.down().withDetail("REASON","Session service failed.").build();
}
return Mono.just(health);
} }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)