diff --git a/src/main/java/com/clearfolio/viewer/controller/HealthController.java b/src/main/java/com/clearfolio/viewer/controller/HealthController.java
index 9975524c..dcdca47b 100644
--- a/src/main/java/com/clearfolio/viewer/controller/HealthController.java
+++ b/src/main/java/com/clearfolio/viewer/controller/HealthController.java
@@ -1,36 +1,81 @@
package com.clearfolio.viewer.controller;
import java.util.Map;
+import java.util.Objects;
+import org.springframework.boot.availability.ApplicationAvailability;
+import org.springframework.boot.availability.LivenessState;
+import org.springframework.boot.availability.ReadinessState;
+import org.springframework.http.CacheControl;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
- * Lightweight endpoint used for process-liveness checks.
+ * Exposes separate liveness and readiness probes on the application port.
*
- *
This endpoint deliberately reports only whether the application process can
- * answer requests. Traffic-readiness semantics are introduced separately so an
- * orchestrator never confuses restart eligibility with dependency readiness.
+ * Liveness answers whether this process can continue operating or needs a
+ * restart. Readiness answers whether the instance should receive traffic. The
+ * two signals deliberately remain separate so a temporary readiness failure
+ * does not trigger a restart cascade.
*/
@RestController
-@RequestMapping("/healthz")
public class HealthController {
+ private final ApplicationAvailability applicationAvailability;
+
/**
- * Creates the stateless liveness controller.
+ * Creates the probe controller from Spring Boot's availability state.
+ *
+ * @param applicationAvailability current application availability provider
*/
- public HealthController() {
- // No mutable state or external dependency belongs in the liveness path.
+ public HealthController(ApplicationAvailability applicationAvailability) {
+ this.applicationAvailability = Objects.requireNonNull(
+ applicationAvailability,
+ "applicationAvailability"
+ );
}
/**
- * Returns a static health payload when the service is alive.
+ * Returns the process liveness state.
*
- * @return health status payload
+ * @return {@code 200} with {@code status=ok} when the process can recover,
+ * otherwise {@code 503} with {@code status=broken}
*/
- @GetMapping
- public Map health() {
- return Map.of("status", "ok");
+ @GetMapping("/healthz")
+ public ResponseEntity