feat: add docker health check

This commit is contained in:
Aarnav Tale
2026-01-13 22:53:40 -05:00
parent 0fb02d0d8b
commit 42ffe69486
5 changed files with 84 additions and 3 deletions
+29
View File
@@ -0,0 +1,29 @@
package main
import (
"fmt"
"net/http"
"os"
"time"
)
func main() {
client := http.Client{
Timeout: 5 * time.Second,
}
resp, err := client.Get("http://localhost:3000/admin/healthz")
if err != nil {
fmt.Fprintf(os.Stderr, "Health check failed: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Fprintf(os.Stderr, "Health check returned non-OK status: %d\n", resp.StatusCode)
os.Exit(1)
}
fmt.Println("Health check passed.")
os.Exit(0)
}