Files
at-container-registry/cmd/healthcheck/main.go
T

23 lines
419 B
Go

// Minimal HTTP health check binary for scratch Docker images.
// Usage: healthcheck <url>
// Exits 0 if the URL returns HTTP 200, 1 otherwise.
package main
import (
"net/http"
"os"
"time"
)
func main() {
if len(os.Args) < 2 {
os.Exit(1)
}
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Get(os.Args[1])
if err != nil || resp.StatusCode != http.StatusOK {
os.Exit(1)
}
os.Exit(0)
}