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
lease:
type: "consul"
advertise-url: "http://${ADVERTISE_IP}:20202"
advertise-url: "http://${ADVERTISE_IP}:8081"
consul:
url: "${CONSUL_URL}"
key: "litefs/navidrome"
# Internal HTTP API for replication
http:
addr: ":20202"
addr: "0.0.0.0:8081"
# The HTTP Proxy routes traffic to handle write-forwarding
# It listens on 8080 inside the container.
@@ -31,4 +31,9 @@ proxy:
- "*.jpg"
- "*.jpeg"
- "*.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
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" {
@@ -39,10 +43,8 @@ job "navidrome-litefs" {
config {
image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/navidrome-litefs:latest"
privileged = true # Still needed for FUSE
ports = ["http", "litefs"]
ports = ["http", "litefs", "health"]
# Removed network_mode = "host"
volumes = [
"/mnt/configs/navidrome_litefs:/var/lib/litefs",
"/mnt/Public/configs/navidrome:/shared_data",
@@ -56,7 +58,7 @@ job "navidrome-litefs" {
# LiteFS Config
CONSUL_URL = "http://${attr.unique.network.ip-address}:8500"
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
ND_DATAFOLDER = "/local/data"
@@ -89,9 +91,9 @@ job "navidrome-litefs" {
port = "http"
check {
type = "script"
command = "/usr/local/bin/litefs"
args = ["is-primary"]
type = "http"
port = "health"
path = "/"
interval = "10s"
timeout = "2s"
}
@@ -103,4 +105,4 @@ job "navidrome-litefs" {
}
}
}
}
}