From 6b7e4df4911ab4529df34cc7e09de023991bda62 Mon Sep 17 00:00:00 2001 From: GAURAV KARMAKAR Date: Sun, 25 Jan 2026 01:24:34 +0530 Subject: [PATCH] feat: make health check fail when task binary is missing --- backend/controllers/healthcheck.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/controllers/healthcheck.go b/backend/controllers/healthcheck.go index 5d555496..a2d1da82 100644 --- a/backend/controllers/healthcheck.go +++ b/backend/controllers/healthcheck.go @@ -3,6 +3,7 @@ package controllers import ( "encoding/json" "net/http" + "os/exec" ) func HealthCheckHandler(w http.ResponseWriter, r *http.Request) { @@ -11,10 +12,20 @@ func HealthCheckHandler(w http.ResponseWriter, r *http.Request) { return } + status := "healthy" + statusCode := http.StatusOK + + // Check if taskwarrior is reachable + _, err := exec.LookPath("task") + if err != nil { + status = "unhealthy: taskwarrior binary not found" + statusCode = http.StatusServiceUnavailable + } + w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) + w.WriteHeader(statusCode) json.NewEncoder(w).Encode(map[string]string{ - "status": "healthy", + "status": status, "service": "ccsync-backend", }) }