fix: implement http health-check responder for primary routing
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 57s

This commit is contained in:
2026-02-07 17:55:56 -08:00
parent 8568f4e9b9
commit 20547c6c25
2 changed files with 18 additions and 11 deletions

View File

@@ -8,14 +8,14 @@ data:
# Use Consul for leader election # Use Consul for leader election
lease: lease:
type: "consul" type: "consul"
advertise-url: "http://${ADVERTISE_IP}:20202" advertise-url: "http://${ADVERTISE_IP}:8081"
consul: consul:
url: "${CONSUL_URL}" url: "${CONSUL_URL}"
key: "litefs/navidrome" key: "litefs/navidrome"
# Internal HTTP API for replication # Internal HTTP API for replication
http: http:
addr: ":20202" addr: "0.0.0.0:8081"
# The HTTP Proxy routes traffic to handle write-forwarding # The HTTP Proxy routes traffic to handle write-forwarding
# It listens on 8080 inside the container. # It listens on 8080 inside the container.
@@ -31,4 +31,9 @@ proxy:
- "*.jpg" - "*.jpg"
- "*.jpeg" - "*.jpeg"
- "*.gif" - "*.gif"
- "*.svg" - "*.svg"
# Commands to run only on the primary node.
# This serves as a primary-only health check responder.
exec:
- cmd: "while true; do echo -e 'HTTP/1.1 200 OK\r\nContent-Length: 7\r\n\r\nPrimary' | nc -l -p 8082; done"

View File

@@ -31,6 +31,10 @@ job "navidrome-litefs" {
static = 20202 static = 20202
to = 20202 # Maps host 20202 to container 20202 (LiteFS Replication) to = 20202 # Maps host 20202 to container 20202 (LiteFS Replication)
} }
port "health" {
static = 8082
to = 8082 # Handled by nc loop in litefs.yml exec
}
} }
task "navidrome" { task "navidrome" {
@@ -39,10 +43,8 @@ job "navidrome-litefs" {
config { config {
image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/navidrome-litefs:latest" image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/navidrome-litefs:latest"
privileged = true # Still needed for FUSE privileged = true # Still needed for FUSE
ports = ["http", "litefs"] ports = ["http", "litefs", "health"]
# Removed network_mode = "host"
volumes = [ volumes = [
"/mnt/configs/navidrome_litefs:/var/lib/litefs", "/mnt/configs/navidrome_litefs:/var/lib/litefs",
"/mnt/Public/configs/navidrome:/shared_data", "/mnt/Public/configs/navidrome:/shared_data",
@@ -56,7 +58,7 @@ job "navidrome-litefs" {
# LiteFS Config # LiteFS Config
CONSUL_URL = "http://${attr.unique.network.ip-address}:8500" CONSUL_URL = "http://${attr.unique.network.ip-address}:8500"
ADVERTISE_IP = "${attr.unique.network.ip-address}" ADVERTISE_IP = "${attr.unique.network.ip-address}"
PORT = "8080" # Internal proxy port PORT = "8080" # Internal proxy port (unused by direct routing but kept for image compat)
# Navidrome Config # Navidrome Config
ND_DATAFOLDER = "/local/data" ND_DATAFOLDER = "/local/data"
@@ -89,9 +91,9 @@ job "navidrome-litefs" {
port = "http" port = "http"
check { check {
type = "script" type = "http"
command = "/usr/local/bin/litefs" port = "health"
args = ["is-primary"] path = "/"
interval = "10s" interval = "10s"
timeout = "2s" timeout = "2s"
} }
@@ -103,4 +105,4 @@ job "navidrome-litefs" {
} }
} }
} }
} }