fix(entrypoint): restore consul registration and cleanup logging
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 43s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 43s
This commit is contained in:
@@ -16,13 +16,12 @@ PRIMARY_TAGS='["navidrome","web","traefik.enable=true","urlprefix-/navidrome","t
|
||||
# Check if this node is the LiteFS Primary
|
||||
# LiteFS 0.5 status API returns a flat object: {"isPrimary": true, ...}
|
||||
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")
|
||||
|
||||
if [ "$is_primary" = "true" ]; then
|
||||
return 0 # We are the primary
|
||||
fi
|
||||
echo "check_primary: Not primary. Status: $status"
|
||||
return 1 # We are a replica
|
||||
}
|
||||
|
||||
@@ -130,15 +129,15 @@ while true; do
|
||||
# === WE ARE PRIMARY ===
|
||||
if [ "${NAVIDROME_PID}" -eq 0 ] || ! kill -0 "${NAVIDROME_PID}" 2>/dev/null; then
|
||||
start_app
|
||||
# register_service
|
||||
register_service
|
||||
fi
|
||||
# pass_ttl
|
||||
pass_ttl
|
||||
else
|
||||
# === WE ARE REPLICA ===
|
||||
if [ "${NAVIDROME_PID}" -gt 0 ]; then
|
||||
echo "Lost leadership. Demoting..."
|
||||
stop_app
|
||||
# deregister_service
|
||||
deregister_service
|
||||
fi
|
||||
fi
|
||||
sleep 10
|
||||
|
||||
Reference in New Issue
Block a user