|
@@ -0,0 +1,37 @@
|
|
|
+//package com.slibra.web.controller.business;
|
|
|
+//
|
|
|
+//import com.slibra.common.core.domain.entity.SysUser;
|
|
|
+//import com.slibra.system.mapper.SysUserMapper;
|
|
|
+//import org.slf4j.Logger;
|
|
|
+//import org.slf4j.LoggerFactory;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.boot.actuate.health.Health;
|
|
|
+//import org.springframework.boot.actuate.health.HealthIndicator;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//@Component
|
|
|
+//public class CustomHealthIndicator implements HealthIndicator {
|
|
|
+//
|
|
|
+// private static final Logger log = LoggerFactory.getLogger(CustomHealthIndicator.class);
|
|
|
+// @Autowired
|
|
|
+// private SysUserMapper sysUserMapper;
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Health health() {
|
|
|
+// // 自定义的健康检查逻辑
|
|
|
+//
|
|
|
+// //查询数据库,如果正常访问,不出现异常,则说明服务是健康的
|
|
|
+// boolean isHealthy = true;
|
|
|
+// try {
|
|
|
+// this.sysUserMapper.selectUserById(1L);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("数据库挂了 或者 连接不到了");
|
|
|
+// isHealthy = false;
|
|
|
+// }
|
|
|
+// if (isHealthy) {
|
|
|
+// return Health.up().build();
|
|
|
+// } else {
|
|
|
+// return Health.down().withDetail("Error", "Service is not available").build();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|