uptimesebi-checker and uptimesebi-statuspage for linux/amd64, arm64, arm/v7 and arm/v6, from a Raspberry Pi Zero to servers. tools/image assembles them from the cross-compiled binaries without Docker or emulation: one layer on an empty base with the binary, a data volume owned by the unprivileged user and a HEALTHCHECK running the new `checker health` / `statuspage health` commands. The binaries embed time zone data and fallback CA roots, so no base image ever needs updating. CI pushes them with the same channel tags as the main image; releases carry tarballs for all four platforms. Refs #128 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
37 lines
886 B
Go
37 lines
886 B
Go
package platform
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// ProbeLocal asks the local health endpoint on listen (e.g. ":8081") whether
|
|
// the process is alive. Images without a shell run it as their HEALTHCHECK.
|
|
func ProbeLocal(ctx context.Context, listen string) error {
|
|
host, port, err := net.SplitHostPort(listen)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if host == "" || host == "0.0.0.0" || host == "::" {
|
|
host = "127.0.0.1"
|
|
}
|
|
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
|
defer cancel()
|
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://"+net.JoinHostPort(host, port)+"/healthz", nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_ = resp.Body.Close()
|
|
if resp.StatusCode >= 300 {
|
|
return fmt.Errorf("platform: health endpoint answered %s", resp.Status)
|
|
}
|
|
return nil
|
|
}
|