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
|
PORT=4533
|
||||||
CONSUL_HTTP_ADDR="${CONSUL_URL:-http://localhost:8500}"
|
CONSUL_HTTP_ADDR="${CONSUL_URL:-http://localhost:8500}"
|
||||||
NODE_IP="${ADVERTISE_IP}"
|
NODE_IP="${ADVERTISE_IP}"
|
||||||
DB_LOCK_FILE="/litefs/.primary"
|
|
||||||
NAVIDROME_PID=0
|
NAVIDROME_PID=0
|
||||||
|
|
||||||
# Tags for the Primary service (Traefik enabled)
|
# Tags for the Primary service (Traefik enabled)
|
||||||
@@ -14,7 +13,6 @@ PRIMARY_TAGS='["navidrome","web","traefik.enable=true","urlprefix-/navidrome","t
|
|||||||
# --- Helper Functions ---
|
# --- Helper Functions ---
|
||||||
|
|
||||||
# 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, ...}
|
|
||||||
check_primary() {
|
check_primary() {
|
||||||
local status=$(curl -s http://localhost:20202/info || echo "{}")
|
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")
|
||||||
@@ -48,6 +46,25 @@ wait_for_litefs() {
|
|||||||
return 1
|
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 with TTL Check
|
||||||
register_service() {
|
register_service() {
|
||||||
echo "Registering service ${SERVICE_ID} with Consul..."
|
echo "Registering service ${SERVICE_ID} with Consul..."
|
||||||
@@ -79,24 +96,19 @@ deregister_service() {
|
|||||||
start_app() {
|
start_app() {
|
||||||
echo "Node is Primary. Starting Navidrome..."
|
echo "Node is Primary. Starting Navidrome..."
|
||||||
|
|
||||||
# Ensure shared directories exist on persistent host volume
|
# Ensure shared directories exist
|
||||||
mkdir -p /local/navidrome_v2/plugins /local/navidrome_v2/cache /local/navidrome_v2/backup
|
mkdir -p /shared_data/plugins /shared_data/cache /shared_data/backup /shared_data/artist_images
|
||||||
|
|
||||||
# 1. Set the DataFolder to the local task mount
|
# Configuration
|
||||||
export ND_DATAFOLDER="/local/navidrome_v2"
|
export ND_DATAFOLDER="/data"
|
||||||
|
export ND_CACHEFOLDER="/shared_data/cache"
|
||||||
# 2. Redirect other folders just in case
|
export ND_BACKUP_PATH="/shared_data/backup"
|
||||||
export ND_CACHEFOLDER="/local/navidrome_v2/cache"
|
export ND_PLUGINS_FOLDER="/shared_data/plugins"
|
||||||
export ND_BACKUP_PATH="/local/navidrome_v2/backup"
|
export ND_ARTISTIMAGEFOLDER="/shared_data/artist_images"
|
||||||
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"
|
|
||||||
|
|
||||||
/app/navidrome &
|
/app/navidrome &
|
||||||
NAVIDROME_PID=$!
|
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
|
# Stop Navidrome
|
||||||
@@ -124,6 +136,9 @@ trap cleanup TERM INT
|
|||||||
echo "Starting Supervisor. Waiting for leadership settle..."
|
echo "Starting Supervisor. Waiting for leadership settle..."
|
||||||
wait_for_litefs || exit 1
|
wait_for_litefs || exit 1
|
||||||
|
|
||||||
|
LAST_BACKUP_TIME=$(date +%s)
|
||||||
|
BACKUP_INTERVAL=86400 # 24 hours
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if check_primary; then
|
if check_primary; then
|
||||||
# === WE ARE PRIMARY ===
|
# === WE ARE PRIMARY ===
|
||||||
@@ -132,6 +147,13 @@ while true; do
|
|||||||
register_service
|
register_service
|
||||||
fi
|
fi
|
||||||
pass_ttl
|
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
|
else
|
||||||
# === WE ARE REPLICA ===
|
# === WE ARE REPLICA ===
|
||||||
if [ "${NAVIDROME_PID}" -gt 0 ]; then
|
if [ "${NAVIDROME_PID}" -gt 0 ]; then
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# LiteFS configuration for Navidrome
|
# LiteFS configuration for Navidrome
|
||||||
fuse:
|
fuse:
|
||||||
dir: "/litefs"
|
dir: "/data"
|
||||||
|
|
||||||
data:
|
data:
|
||||||
dir: "/var/lib/litefs"
|
dir: "/var/lib/litefs"
|
||||||
@@ -13,7 +13,7 @@ lease:
|
|||||||
advertise-url: "http://${ADVERTISE_IP}:20202"
|
advertise-url: "http://${ADVERTISE_IP}:20202"
|
||||||
consul:
|
consul:
|
||||||
url: "${CONSUL_URL}"
|
url: "${CONSUL_URL}"
|
||||||
key: "${LITEFS_CONSUL_KEY}"
|
key: "litefs/navidrome"
|
||||||
ttl: "30s"
|
ttl: "30s"
|
||||||
lock-delay: "5s"
|
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" {
|
group "navidrome" {
|
||||||
count = 3
|
count = 4
|
||||||
|
|
||||||
update {
|
update {
|
||||||
max_parallel = 1
|
max_parallel = 1
|
||||||
@@ -26,12 +26,6 @@ job "navidrome-litefs" {
|
|||||||
distinct_hosts = true
|
distinct_hosts = true
|
||||||
}
|
}
|
||||||
|
|
||||||
constraint {
|
|
||||||
attribute = "${attr.unique.hostname}"
|
|
||||||
operator = "!="
|
|
||||||
value = "odroid7"
|
|
||||||
}
|
|
||||||
|
|
||||||
network {
|
network {
|
||||||
# Request static ports on the host
|
# Request static ports on the host
|
||||||
port "http" {
|
port "http" {
|
||||||
@@ -54,34 +48,34 @@ job "navidrome-litefs" {
|
|||||||
force_pull = true
|
force_pull = true
|
||||||
|
|
||||||
volumes = [
|
volumes = [
|
||||||
"/mnt/configs/navidrome_litefs_v2:/var/lib/litefs",
|
"/mnt/configs/navidrome_litefs:/var/lib/litefs",
|
||||||
"/mnt/Public/configs/navidrome:/data",
|
"/mnt/Public/configs/navidrome:/shared_data",
|
||||||
"/mnt/Public/Downloads/Clean_Music:/music/CleanMusic:ro",
|
"/mnt/Public/Downloads/Clean_Music:/music/CleanMusic:ro",
|
||||||
"/mnt/Public/Downloads/news/slskd/downloads:/music/slskd:ro",
|
"/mnt/Public/Downloads/news/slskd/downloads:/music/slskd:ro",
|
||||||
"/mnt/Public/Downloads/incoming_music:/music/incomingmusic:ro"
|
"/mnt/Public/Downloads/incoming_music:/music/incomingmusic:ro"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
env {
|
env {
|
||||||
# LiteFS Config
|
# LiteFS Config
|
||||||
CONSUL_URL = "http://${attr.unique.network.ip-address}:8500"
|
CONSUL_URL = "http://${attr.unique.network.ip-address}:8500"
|
||||||
ADVERTISE_IP = "${attr.unique.network.ip-address}"
|
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
|
# Navidrome Config
|
||||||
ND_DATAFOLDER = "/data"
|
ND_DATAFOLDER = "/data"
|
||||||
ND_PLUGINS_FOLDER = "/data/plugins"
|
ND_PLUGINS_FOLDER = "/shared_data/plugins"
|
||||||
ND_CACHEFOLDER = "/data/cache"
|
ND_CACHEFOLDER = "/shared_data/cache"
|
||||||
ND_BACKUP_PATH = "/data/backup"
|
ND_BACKUP_PATH = "/shared_data/backup"
|
||||||
|
ND_ARTISTIMAGEFOLDER = "/shared_data/artist_images"
|
||||||
ND_BACKUPSCHEDULE = ""
|
ND_BACKUPSCHEDULE = ""
|
||||||
|
|
||||||
ND_SCANSCHEDULE = "0"
|
ND_SCANSCHEDULE = "0"
|
||||||
ND_SCANNER_FSWATCHER_ENABLED = "false"
|
ND_SCANNER_FSWATCHER_ENABLED = "false"
|
||||||
ND_FORCE_REDEPLOY = "5"
|
ND_FORCE_REDEPLOY = "5"
|
||||||
ND_LOGLEVEL = "info"
|
ND_LOGLEVEL = "info"
|
||||||
ND_EXTAUTH_TRUSTEDSOURCES = "0.0.0.0/0"
|
ND_REVERSEPROXYWHITELIST = "0.0.0.0/0"
|
||||||
ND_EXTAUTH_USERHEADER = "X-Forwarded-User"
|
ND_REVERSEPROXYUSERHEADER = "X-Forwarded-User"
|
||||||
}
|
}
|
||||||
|
|
||||||
# NO service block here! Managed by register.sh inside the container.
|
# 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