adding docker health checks

This commit is contained in:
lone-cloud 2026-03-28 21:55:20 -07:00
parent 8c929c925b
commit a260863106
4 changed files with 13 additions and 2 deletions

View file

@ -20,4 +20,7 @@ RUN VERSION=$(cat /tmp/VERSION) && \
EXPOSE 8888 EXPOSE 8888
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:8888/health || exit 1
CMD ["/app/server"] CMD ["/app/server"]

View file

@ -1 +1 @@
1.8.0 1.9.0

View file

@ -30,6 +30,7 @@ func main() {
fs := http.FileServer(http.Dir("/app/static")) fs := http.FileServer(http.Dir("/app/static"))
mux.Handle("/", fs) mux.Handle("/", fs)
mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })
mux.HandleFunc("/api/nat", handleNAT) mux.HandleFunc("/api/nat", handleNAT)
mux.HandleFunc("/api/logs", handleLogs) mux.HandleFunc("/api/logs", handleLogs)
mux.HandleFunc("/api/metrics", handleMetrics) mux.HandleFunc("/api/metrics", handleMetrics)

View file

@ -7,7 +7,8 @@ services:
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
depends_on: depends_on:
- snowflake-proxy snowflake-proxy:
condition: service_healthy
snowflake-proxy: snowflake-proxy:
container_name: snowflake-proxy container_name: snowflake-proxy
@ -17,6 +18,12 @@ services:
# For a full list of Snowflake Proxy CLI parameters see # For a full list of Snowflake Proxy CLI parameters see
# https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/tree/main/proxy?ref_type=heads#running-a-standalone-snowflake-proxy # https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/tree/main/proxy?ref_type=heads#running-a-standalone-snowflake-proxy
command: ["-metrics", "-metrics-address", "0.0.0.0", "-metrics-port", "9999"] command: ["-metrics", "-metrics-address", "0.0.0.0", "-metrics-port", "9999"]
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:9999/metrics"]
interval: 30s
timeout: 5s
start_period: 10s
retries: 3
# Optionally limit ephemeral port range for firewall rules: # Optionally limit ephemeral port range for firewall rules:
# command: ["-metrics", "-metrics-address", "0.0.0.0", "-metrics-port", "9999", "-ephemeral-ports-range", "30000:60000"] # command: ["-metrics", "-metrics-address", "0.0.0.0", "-metrics-port", "9999", "-ephemeral-ports-range", "30000:60000"]