fix: relocate LiteFS mount to /litefs and use /data for persistent artwork
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 4m5s

This commit is contained in:
2026-04-27 08:04:06 -07:00
parent f08c715d75
commit 59f406d3b7
4 changed files with 25 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ SERVICE_ID="${SERVICE_NAME}-${NOMAD_ALLOC_ID:-$(hostname)}"
PORT=4533
CONSUL_HTTP_ADDR="${CONSUL_URL:-http://localhost:8500}"
NODE_IP="${ADVERTISE_IP}"
DB_LOCK_FILE="/data/.primary"
DB_LOCK_FILE="/litefs/.primary"
NAVIDROME_PID=0
# Tags for the Primary service (Traefik enabled)
@@ -16,9 +16,21 @@ PRIMARY_TAGS='["navidrome","web","traefik.enable=true","urlprefix-/navidrome","t
# --- Helper Functions ---
# Ensure Navidrome's data directory exists and has the database symlinked to LiteFS
setup_data_dir() {
echo "Setting up Navidrome data directory..."
mkdir -p /data
# Symlink the database and its sidecar files to the LiteFS mount.
# This ensures SQLite writes go through LiteFS while Navidrome can still
# create subdirectories (like /data/artwork) on the persistent host volume.
ln -sf /litefs/navidrome.db /data/navidrome.db
ln -sf /litefs/navidrome.db-wal /data/navidrome.db-wal
ln -sf /litefs/navidrome.db-shm /data/navidrome.db-shm
}
# Backup Database (Only on Primary)
run_backup() {
local backup_dir="/shared_data/backup"
local backup_dir="/data/backup"
local timestamp=$(date +%Y%m%d_%H%M%S)
local backup_file="${backup_dir}/navidrome.db_${timestamp}.bak"
@@ -68,7 +80,7 @@ start_app() {
echo "Node is Primary. Starting Navidrome..."
# Ensure shared directories exist
mkdir -p /shared_data/plugins /shared_data/cache /shared_data/backup
mkdir -p /data/plugins /data/cache /data/backup
/app/navidrome &
NAVIDROME_PID=$!
@@ -99,6 +111,7 @@ trap cleanup TERM INT
# --- Main Loop ---
echo "Starting Supervisor. Waiting for leadership settle..."
setup_data_dir
echo "Node IP: $NODE_IP"
echo "Consul: $CONSUL_HTTP_ADDR"