-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathhealthz
More file actions
executable file
·15 lines (15 loc) · 771 Bytes
/
Copy pathhealthz
File metadata and controls
executable file
·15 lines (15 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# CGI health endpoint, served by busybox httpd (started in start.sh).
# Fly's health check (see [checks] in fly.toml) requests /cgi-bin/healthz on
# port 9002 and expects a 2xx response.
#
# We can't use Tailscale's built-in TS_ENABLE_HEALTH_CHECK because that's a
# containerboot feature of the official image; this repo runs raw tailscaled.
#
# Returns 200 only when the node is actually connected to the tailnet, and 503
# otherwise (e.g. tailscaled crashed or was OOM-killed, or auth failed).
if /app/tailscale status --json 2>/dev/null | grep -Eq '"BackendState":[[:space:]]*"Running"'; then
printf 'Status: 200 OK\r\nContent-Type: text/plain\r\n\r\nok\n'
else
printf 'Status: 503 Service Unavailable\r\nContent-Type: text/plain\r\n\r\nunhealthy\n'
fi