mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-03 00:36:56 +00:00
23 lines
419 B
Go
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)
|
|
}
|