docker healthcheck

This commit is contained in:
2025-02-28 21:46:05 +00:00
parent f957088bea
commit c9806d5fe9
3 changed files with 17 additions and 7 deletions

View File

@@ -1,14 +1,24 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
resp, err := http.Get("http://localhost:3000/health")
if err != nil || resp.StatusCode != 200 {
if err != nil {
log.Fatalf("Error performing health check: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
log.Printf("Health check failed: Status code %d", resp.StatusCode)
os.Exit(1)
}
fmt.Println("OK")
os.Exit(0)
}