fix(entrypoint): restore consul registration and cleanup logging
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 43s

This commit is contained in:
2026-04-27 11:04:00 -07:00
parent 33b84be0a5
commit 92f9209dcd

View File

@@ -16,13 +16,12 @@ PRIMARY_TAGS='["navidrome","web","traefik.enable=true","urlprefix-/navidrome","t
# Check if this node is the LiteFS Primary # Check if this node is the LiteFS Primary
# LiteFS 0.5 status API returns a flat object: {"isPrimary": true, ...} # LiteFS 0.5 status API returns a flat object: {"isPrimary": true, ...}
check_primary() { check_primary() {
local status=$(curl -s http://localhost:20202/info || echo "{\"error\": \"curl failed\"}") local status=$(curl -s http://localhost:20202/info || echo "{}")
local is_primary=$(echo "$status" | jq -r 'if type == "object" then (.isPrimary // false) else false end' 2>/dev/null || echo "false") local is_primary=$(echo "$status" | jq -r 'if type == "object" then (.isPrimary // false) else false end' 2>/dev/null || echo "false")
if [ "$is_primary" = "true" ]; then if [ "$is_primary" = "true" ]; then
return 0 # We are the primary return 0 # We are the primary
fi fi
echo "check_primary: Not primary. Status: $status"
return 1 # We are a replica return 1 # We are a replica
} }
@@ -130,15 +129,15 @@ while true; do
# === WE ARE PRIMARY === # === WE ARE PRIMARY ===
if [ "${NAVIDROME_PID}" -eq 0 ] || ! kill -0 "${NAVIDROME_PID}" 2>/dev/null; then if [ "${NAVIDROME_PID}" -eq 0 ] || ! kill -0 "${NAVIDROME_PID}" 2>/dev/null; then
start_app start_app
# register_service register_service
fi fi
# pass_ttl pass_ttl
else else
# === WE ARE REPLICA === # === WE ARE REPLICA ===
if [ "${NAVIDROME_PID}" -gt 0 ]; then if [ "${NAVIDROME_PID}" -gt 0 ]; then
echo "Lost leadership. Demoting..." echo "Lost leadership. Demoting..."
stop_app stop_app
# deregister_service deregister_service
fi fi
fi fi
sleep 10 sleep 10