fix: robust leadership detection via LiteFS API and resolve Navidrome deprecation warnings
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:
@@ -15,30 +15,33 @@ NAVIDROME_PID=0
|
||||
|
||||
# Check if this node is the LiteFS Primary
|
||||
check_primary() {
|
||||
# Role: primary or Role: replica
|
||||
local role=$(litefs status 2>/dev/null | grep "Role" | awk '{print $2}' || echo "unknown")
|
||||
if [ "$role" = "primary" ]; then
|
||||
return 0 # Success, we are primary
|
||||
# Use the local LiteFS API to get the most accurate status
|
||||
local status=$(curl -s http://localhost:20202/status || echo "{}")
|
||||
local is_primary=$(echo "$status" | jq -r '.isPrimary // false')
|
||||
|
||||
if [ "$is_primary" = "true" ]; then
|
||||
return 0 # We are the primary
|
||||
fi
|
||||
return 1 # Not primary
|
||||
return 1 # We are a replica
|
||||
}
|
||||
|
||||
# Wait for LiteFS to be "Ready" (connected to cluster)
|
||||
# Wait for LiteFS to be fully initialized and connected
|
||||
wait_for_litefs() {
|
||||
echo "Waiting for LiteFS to initialize..."
|
||||
echo "Waiting for LiteFS to settle..."
|
||||
local timeout=60
|
||||
local count=0
|
||||
while [ $count -lt $timeout ]; do
|
||||
# Check if LiteFS is ready by looking for any role in status
|
||||
if litefs status 2>/dev/null | grep -q "Role"; then
|
||||
echo "LiteFS is initialized."
|
||||
local status=$(curl -s http://localhost:20202/status || echo "{}")
|
||||
# If isPrimary is not null, LiteFS has determined its role
|
||||
if [ "$(echo "$status" | jq -r '.isPrimary // "null"')" != "null" ]; then
|
||||
echo "LiteFS initialized. Role: $(echo "$status" | jq -r '.isPrimary | if . then "primary" else "replica" end')"
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
count=$((count + 2))
|
||||
echo -n "."
|
||||
done
|
||||
echo "ERROR: LiteFS failed to initialize after ${timeout}s"
|
||||
echo "ERROR: LiteFS failed to settle after ${timeout}s"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ job "navidrome-litefs" {
|
||||
ND_SCANNER_FSWATCHER_ENABLED = "false"
|
||||
ND_FORCE_REDEPLOY = "5"
|
||||
ND_LOGLEVEL = "info"
|
||||
ND_REVERSEPROXYWHITELIST = "0.0.0.0/0"
|
||||
ND_REVERSEPROXYUSERHEADER = "X-Forwarded-User"
|
||||
ND_EXTAUTH_TRUSTEDSOURCES = "0.0.0.0/0"
|
||||
ND_EXTAUTH_USERHEADER = "X-Forwarded-User"
|
||||
}
|
||||
|
||||
# NO service block here! Managed by register.sh inside the container.
|
||||
|
||||
Reference in New Issue
Block a user