Probe a service by issuing an HTTP GET. The check passes when the server responds with a 2xx status.
# HTTP health check: probe a service by issuing an HTTP GET.
processes:
- name: web
command: /usr/local/bin/web
args: ["--listen", "127.0.0.1:PORT"]
on-failure: shutdown
checks:
web-http:
http:
url: http://127.0.0.1:PORT/
period: 300ms
threshold: 1http.urlis fetched everyperiod; a 2xx response is healthy.thresholdis the number of consecutive failures before the check is marked unhealthy.- For HTTP over a Unix socket, add
socket: /path/to.sockunderhttp:and keep a normalurl. - In a real config,
commandis your web service andurlis its health endpoint (e.g./healthz). For a quick manual experiment,python3 -m http.server 8080 --bind 127.0.0.1works as a stand-in service.
-
gopherd starts
weband theweb-httpcheck. -
Once the server binds, the GET probe returns 200 and the check reports
healthy:checks: web-http healthy failures=0 -
If the endpoint is unreachable or returns non-2xx, the check trends
unhealthyoncethresholdis reached.
Run level. PORT is substituted with an OS-assigned free port and the placeholder command with a small Go HTTP responder built by the test harness (internal/doctest/cmd/httpok) — no external interpreter needed. The test waits for the probe to get a 2xx and asserts the web-http line is healthy.
go test ./documentation/health-check-http/ -v