fix: revert to original data paths and add ND_ARTISTIMAGEFOLDER
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:
@@ -1,18 +0,0 @@
|
||||
job "disk-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
group "check" {
|
||||
count = 6 # Check all nodes
|
||||
constraint {
|
||||
distinct_hosts = true
|
||||
}
|
||||
task "df" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "df"
|
||||
args = ["-h"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ 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="/litefs/.primary"
|
||||
NAVIDROME_PID=0
|
||||
|
||||
# Tags for the Primary service (Traefik enabled)
|
||||
@@ -14,7 +13,6 @@ PRIMARY_TAGS='["navidrome","web","traefik.enable=true","urlprefix-/navidrome","t
|
||||
# --- Helper Functions ---
|
||||
|
||||
# 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 "{}")
|
||||
local is_primary=$(echo "$status" | jq -r 'if type == "object" then (.isPrimary // false) else false end' 2>/dev/null || echo "false")
|
||||
@@ -48,6 +46,25 @@ wait_for_litefs() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Backup Database (Only on Primary)
|
||||
run_backup() {
|
||||
local backup_dir="/shared_data/backup"
|
||||
local timestamp=$(date +%Y%m%d_%H%M%S)
|
||||
local backup_file="${backup_dir}/navidrome.db_${timestamp}.bak"
|
||||
|
||||
echo "Backing up database to ${backup_file}..."
|
||||
mkdir -p "$backup_dir"
|
||||
|
||||
if litefs export -name navidrome.db "$backup_file"; then
|
||||
echo "Backup successful."
|
||||
# Keep only last 7 days
|
||||
find "$backup_dir" -name "navidrome.db_*.bak" -mtime +7 -delete
|
||||
echo "Old backups cleaned."
|
||||
else
|
||||
echo "ERROR: Backup failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
# Register Service with TTL Check
|
||||
register_service() {
|
||||
echo "Registering service ${SERVICE_ID} with Consul..."
|
||||
@@ -79,24 +96,19 @@ deregister_service() {
|
||||
start_app() {
|
||||
echo "Node is Primary. Starting Navidrome..."
|
||||
|
||||
# Ensure shared directories exist on persistent host volume
|
||||
mkdir -p /local/navidrome_v2/plugins /local/navidrome_v2/cache /local/navidrome_v2/backup
|
||||
# Ensure shared directories exist
|
||||
mkdir -p /shared_data/plugins /shared_data/cache /shared_data/backup /shared_data/artist_images
|
||||
|
||||
# 1. Set the DataFolder to the local task mount
|
||||
export ND_DATAFOLDER="/local/navidrome_v2"
|
||||
|
||||
# 2. Redirect other folders just in case
|
||||
export ND_CACHEFOLDER="/local/navidrome_v2/cache"
|
||||
export ND_BACKUP_PATH="/local/navidrome_v2/backup"
|
||||
export ND_PLUGINS_FOLDER="/local/navidrome_v2/plugins"
|
||||
|
||||
# 3. Start Navidrome with ND_DBPATH environment variable.
|
||||
# This is the most authoritative way to set the DB location.
|
||||
export ND_DBPATH="/litefs/navidrome_v2.db?_busy_timeout=15000"
|
||||
# Configuration
|
||||
export ND_DATAFOLDER="/data"
|
||||
export ND_CACHEFOLDER="/shared_data/cache"
|
||||
export ND_BACKUP_PATH="/shared_data/backup"
|
||||
export ND_PLUGINS_FOLDER="/shared_data/plugins"
|
||||
export ND_ARTISTIMAGEFOLDER="/shared_data/artist_images"
|
||||
|
||||
/app/navidrome &
|
||||
NAVIDROME_PID=$!
|
||||
echo "Navidrome running (PID: $NAVIDROME_PID) with database at /litefs"
|
||||
echo "Navidrome running (PID: $NAVIDROME_PID) with data folder at /data"
|
||||
}
|
||||
|
||||
# Stop Navidrome
|
||||
@@ -124,6 +136,9 @@ trap cleanup TERM INT
|
||||
echo "Starting Supervisor. Waiting for leadership settle..."
|
||||
wait_for_litefs || exit 1
|
||||
|
||||
LAST_BACKUP_TIME=$(date +%s)
|
||||
BACKUP_INTERVAL=86400 # 24 hours
|
||||
|
||||
while true; do
|
||||
if check_primary; then
|
||||
# === WE ARE PRIMARY ===
|
||||
@@ -132,6 +147,13 @@ while true; do
|
||||
register_service
|
||||
fi
|
||||
pass_ttl
|
||||
|
||||
# Handle periodic backup
|
||||
CURRENT_TIME=$(date +%s)
|
||||
if [ $((CURRENT_TIME - LAST_BACKUP_TIME)) -ge $BACKUP_INTERVAL ]; then
|
||||
run_backup
|
||||
LAST_BACKUP_TIME=$CURRENT_TIME
|
||||
fi
|
||||
else
|
||||
# === WE ARE REPLICA ===
|
||||
if [ "${NAVIDROME_PID}" -gt 0 ]; then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# LiteFS configuration for Navidrome
|
||||
fuse:
|
||||
dir: "/litefs"
|
||||
dir: "/data"
|
||||
|
||||
data:
|
||||
dir: "/var/lib/litefs"
|
||||
@@ -13,7 +13,7 @@ lease:
|
||||
advertise-url: "http://${ADVERTISE_IP}:20202"
|
||||
consul:
|
||||
url: "${CONSUL_URL}"
|
||||
key: "${LITEFS_CONSUL_KEY}"
|
||||
key: "litefs/navidrome"
|
||||
ttl: "30s"
|
||||
lock-delay: "5s"
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
job "mnt-configs-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
group "check" {
|
||||
count = 4
|
||||
constraint {
|
||||
distinct_hosts = true
|
||||
}
|
||||
task "df" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "df"
|
||||
args = ["-h", "/mnt/configs"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ job "navidrome-litefs" {
|
||||
}
|
||||
|
||||
group "navidrome" {
|
||||
count = 3
|
||||
count = 4
|
||||
|
||||
update {
|
||||
max_parallel = 1
|
||||
@@ -26,12 +26,6 @@ job "navidrome-litefs" {
|
||||
distinct_hosts = true
|
||||
}
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
operator = "!="
|
||||
value = "odroid7"
|
||||
}
|
||||
|
||||
network {
|
||||
# Request static ports on the host
|
||||
port "http" {
|
||||
@@ -54,34 +48,34 @@ job "navidrome-litefs" {
|
||||
force_pull = true
|
||||
|
||||
volumes = [
|
||||
"/mnt/configs/navidrome_litefs_v2:/var/lib/litefs",
|
||||
"/mnt/Public/configs/navidrome:/data",
|
||||
"/mnt/configs/navidrome_litefs:/var/lib/litefs",
|
||||
"/mnt/Public/configs/navidrome:/shared_data",
|
||||
"/mnt/Public/Downloads/Clean_Music:/music/CleanMusic:ro",
|
||||
"/mnt/Public/Downloads/news/slskd/downloads:/music/slskd:ro",
|
||||
"/mnt/Public/Downloads/incoming_music:/music/incomingmusic:ro"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
env {
|
||||
env {
|
||||
# LiteFS Config
|
||||
CONSUL_URL = "http://${attr.unique.network.ip-address}:8500"
|
||||
ADVERTISE_IP = "${attr.unique.network.ip-address}"
|
||||
LITEFS_CONSUL_KEY = "litefs/navidrome-v2"
|
||||
PORT = "8080" # Internal proxy port (unused but kept)"
|
||||
PORT = "8080" # Internal proxy port (unused but kept)
|
||||
|
||||
# Navidrome Config
|
||||
ND_DATAFOLDER = "/data"
|
||||
ND_PLUGINS_FOLDER = "/data/plugins"
|
||||
ND_CACHEFOLDER = "/data/cache"
|
||||
ND_BACKUP_PATH = "/data/backup"
|
||||
ND_PLUGINS_FOLDER = "/shared_data/plugins"
|
||||
ND_CACHEFOLDER = "/shared_data/cache"
|
||||
ND_BACKUP_PATH = "/shared_data/backup"
|
||||
ND_ARTISTIMAGEFOLDER = "/shared_data/artist_images"
|
||||
ND_BACKUPSCHEDULE = ""
|
||||
|
||||
ND_SCANSCHEDULE = "0"
|
||||
ND_SCANNER_FSWATCHER_ENABLED = "false"
|
||||
ND_FORCE_REDEPLOY = "5"
|
||||
ND_LOGLEVEL = "info"
|
||||
ND_EXTAUTH_TRUSTEDSOURCES = "0.0.0.0/0"
|
||||
ND_EXTAUTH_USERHEADER = "X-Forwarded-User"
|
||||
ND_REVERSEPROXYWHITELIST = "0.0.0.0/0"
|
||||
ND_REVERSEPROXYUSERHEADER = "X-Forwarded-User"
|
||||
}
|
||||
|
||||
# NO service block here! Managed by register.sh inside the container.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
job "odroid7-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
value = "odroid7"
|
||||
}
|
||||
|
||||
group "check" {
|
||||
task "df" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "bash"
|
||||
args = ["-c", "df -h; sleep 60"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
job "odroid7-docker-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
value = "odroid7"
|
||||
}
|
||||
|
||||
group "check" {
|
||||
task "ps" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "docker"
|
||||
args = ["ps", "--filter", "name=navidrome-litefs"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
job "odroid8-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
value = "odroid8"
|
||||
}
|
||||
|
||||
group "check" {
|
||||
task "df" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "df"
|
||||
args = ["-h"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
job "odroid8-disk-check" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
value = "odroid8"
|
||||
}
|
||||
|
||||
group "check" {
|
||||
task "df" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "bash"
|
||||
args = ["-c", "df -h; sleep 60"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user