fix(health): 添加 /api/v1/health 端点并修正 mci-server 健康检查
- HealthController: 提供无鉴权健康检查接口,返回 {status: ok}
- AuthInterceptor/WebConfig: 放行 /api/v1/health
- docker-compose.yml: mci-server 健康检查地址改为 /msg-platform/api/v1/health
注意:mci-server Docker 镜像当前因 Maven Central 无法解析 spring-boot-maven-plugin:4.1.0 而无法重新构建,健康检查修复已入库,待网络恢复后重新构建即可生效。
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
package com.sino.mci.admin.controller;
|
||||||
|
|
||||||
|
import com.sino.mci.shared.web.ApiResponse;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/health")
|
||||||
|
public class HealthController {
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ApiResponse<Map<String, String>> health() {
|
||||||
|
return ApiResponse.ok(Map.of("status", "ok"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,8 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|||||||
String method = request.getMethod();
|
String method = request.getMethod();
|
||||||
if (path.contains("/api/v1/account/login")
|
if (path.contains("/api/v1/account/login")
|
||||||
|| ("POST".equals(method) && isExactPath(path, "/api/v1/account/tenant"))
|
|| ("POST".equals(method) && isExactPath(path, "/api/v1/account/tenant"))
|
||||||
|| ("POST".equals(method) && isExactPath(path, "/api/v1/account/user"))) {
|
|| ("POST".equals(method) && isExactPath(path, "/api/v1/account/user"))
|
||||||
|
|| isExactPath(path, "/api/v1/health")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
.excludePathPatterns(
|
.excludePathPatterns(
|
||||||
"/msg-platform/api/v1/account/login", "/api/v1/account/login",
|
"/msg-platform/api/v1/account/login", "/api/v1/account/login",
|
||||||
"/msg-platform/api/v1/account/tenant", "/api/v1/account/tenant",
|
"/msg-platform/api/v1/account/tenant", "/api/v1/account/tenant",
|
||||||
"/msg-platform/api/v1/account/user", "/api/v1/account/user");
|
"/msg-platform/api/v1/account/user", "/api/v1/account/user",
|
||||||
|
"/msg-platform/api/v1/health", "/api/v1/health");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ services:
|
|||||||
rabbitmq:
|
rabbitmq:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-fsS", "http://localhost:8080/msg-platform/actuator/health"]
|
test: ["CMD", "curl", "-fsS", "http://localhost:8080/msg-platform/api/v1/health"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 15
|
retries: 15
|
||||||
|
|||||||
Reference in New Issue
Block a user