Make mount point optional when config file provides it
- CLI mountpoint argument is now Option<PathBuf> - Falls back to config.mount_point when --config is provided - CLI mountpoint still overrides config if both are given - Expanded config.example.toml with all available options
This commit is contained in:
+84
-2
@@ -1,25 +1,107 @@
|
|||||||
|
# MusicFS Configuration
|
||||||
|
# Copy to /etc/musicfs/config.toml or ~/.config/musicfs/config.toml
|
||||||
|
|
||||||
|
# Required: where to mount the virtual filesystem
|
||||||
mount_point = "/mnt/music"
|
mount_point = "/mnt/music"
|
||||||
|
|
||||||
|
# Required: directory for cache data (CAS chunks, metadata, search index)
|
||||||
cache_dir = "/var/cache/musicfs"
|
cache_dir = "/var/cache/musicfs"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Origins - music sources (at least one required)
|
||||||
|
# Supported types: local, nfs, smb, s3, sftp
|
||||||
|
# Lower priority number = preferred source for failover
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
[[origins]]
|
[[origins]]
|
||||||
id = "local-storage"
|
id = "local-music"
|
||||||
origin_type = "local"
|
origin_type = "local"
|
||||||
priority = 1
|
priority = 1
|
||||||
enabled = true
|
enabled = true
|
||||||
path = "/path/to/local/music"
|
path = "/home/user/Music"
|
||||||
|
|
||||||
|
[[origins]]
|
||||||
|
id = "nas-nfs"
|
||||||
|
origin_type = "nfs"
|
||||||
|
priority = 2
|
||||||
|
enabled = true
|
||||||
|
path = "/mnt/nas/music"
|
||||||
|
|
||||||
|
[[origins]]
|
||||||
|
id = "nas-smb"
|
||||||
|
origin_type = "smb"
|
||||||
|
priority = 3
|
||||||
|
enabled = false
|
||||||
|
path = "/mnt/smb/music"
|
||||||
|
|
||||||
|
[[origins]]
|
||||||
|
id = "cloud-backup"
|
||||||
|
origin_type = "s3"
|
||||||
|
priority = 10
|
||||||
|
enabled = false
|
||||||
|
bucket = "my-music-backup"
|
||||||
|
region = "us-east-1"
|
||||||
|
|
||||||
|
[[origins]]
|
||||||
|
id = "remote-server"
|
||||||
|
origin_type = "sftp"
|
||||||
|
priority = 10
|
||||||
|
enabled = false
|
||||||
|
host = "music.example.com"
|
||||||
|
port = 22
|
||||||
|
user = "musicfs"
|
||||||
|
path = "/srv/music"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Cache settings
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
[cache]
|
[cache]
|
||||||
|
# In-memory metadata cache size (artist/album/track info)
|
||||||
metadata_cache_mb = 100
|
metadata_cache_mb = 100
|
||||||
|
|
||||||
|
# On-disk content cache size (audio chunks)
|
||||||
content_cache_gb = 10
|
content_cache_gb = 10
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Health monitoring for origin failover
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
[health]
|
[health]
|
||||||
|
# How often to check origin health
|
||||||
check_interval_secs = 30
|
check_interval_secs = 30
|
||||||
|
|
||||||
|
# Timeout for health check probes
|
||||||
timeout_ms = 5000
|
timeout_ms = 5000
|
||||||
|
|
||||||
|
# Consecutive failures before marking origin unhealthy
|
||||||
unhealthy_threshold = 3
|
unhealthy_threshold = 3
|
||||||
|
|
||||||
|
# Per-origin type thresholds (overrides unhealthy_threshold)
|
||||||
|
[health.per_origin_thresholds]
|
||||||
|
local = 1
|
||||||
|
nfs = 3
|
||||||
|
smb = 3
|
||||||
|
s3 = 3
|
||||||
|
sftp = 3
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Logging
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
[logging]
|
[logging]
|
||||||
|
# Directory for log files
|
||||||
log_dir = "/var/log/musicfs"
|
log_dir = "/var/log/musicfs"
|
||||||
|
|
||||||
|
# Output logs as JSON (for log aggregators)
|
||||||
json_output = false
|
json_output = false
|
||||||
|
|
||||||
|
# Send logs to systemd journal
|
||||||
journald = true
|
journald = true
|
||||||
|
|
||||||
|
# Log level filter (tracing format)
|
||||||
|
# Examples: "info", "debug", "musicfs=debug,warn", "musicfs_fuse=trace"
|
||||||
level = "musicfs=info,warn"
|
level = "musicfs=info,warn"
|
||||||
|
|
||||||
|
# Trace sampling rate for performance tracing (0.0 to 1.0)
|
||||||
trace_sample_rate = 1.0
|
trace_sample_rate = 1.0
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ enum Commands {
|
|||||||
Mount {
|
Mount {
|
||||||
#[arg(short, long, help = "Config file path")]
|
#[arg(short, long, help = "Config file path")]
|
||||||
config: Option<PathBuf>,
|
config: Option<PathBuf>,
|
||||||
#[arg(help = "Mount point")]
|
#[arg(help = "Mount point (optional if provided in config file)")]
|
||||||
mountpoint: PathBuf,
|
mountpoint: Option<PathBuf>,
|
||||||
#[arg(short, long, help = "Source music directory")]
|
#[arg(short, long, help = "Source music directory")]
|
||||||
origin: Option<PathBuf>,
|
origin: Option<PathBuf>,
|
||||||
#[arg(short = 'd', long, help = "Cache directory")]
|
#[arg(short = 'd', long, help = "Cache directory")]
|
||||||
@@ -127,6 +127,9 @@ fn main() -> Result<()> {
|
|||||||
} else {
|
} else {
|
||||||
let origin_path = origin
|
let origin_path = origin
|
||||||
.context("--origin is required for mount if no config file is provided")?;
|
.context("--origin is required for mount if no config file is provided")?;
|
||||||
|
let mp = mountpoint
|
||||||
|
.clone()
|
||||||
|
.context("mount point is required if no config file is provided")?;
|
||||||
let cache_dir = cache_dir.clone().unwrap_or_else(|| {
|
let cache_dir = cache_dir.clone().unwrap_or_else(|| {
|
||||||
dirs::cache_dir()
|
dirs::cache_dir()
|
||||||
.unwrap_or_else(|| PathBuf::from("/tmp"))
|
.unwrap_or_else(|| PathBuf::from("/tmp"))
|
||||||
@@ -140,7 +143,7 @@ fn main() -> Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
musicfs_core::Config {
|
musicfs_core::Config {
|
||||||
mount_point: mountpoint.clone(),
|
mount_point: mp,
|
||||||
cache_dir: cache_dir.clone(),
|
cache_dir: cache_dir.clone(),
|
||||||
origins: vec![musicfs_core::OriginConfig {
|
origins: vec![musicfs_core::OriginConfig {
|
||||||
id: "local".to_string(),
|
id: "local".to_string(),
|
||||||
@@ -161,7 +164,9 @@ fn main() -> Result<()> {
|
|||||||
if let Some(c_dir) = cache_dir {
|
if let Some(c_dir) = cache_dir {
|
||||||
config.cache_dir = c_dir;
|
config.cache_dir = c_dir;
|
||||||
}
|
}
|
||||||
config.mount_point = mountpoint;
|
if let Some(cli_mountpoint) = mountpoint {
|
||||||
|
config.mount_point = cli_mountpoint;
|
||||||
|
}
|
||||||
|
|
||||||
let _guard = init_logging(&config.logging)?;
|
let _guard = init_logging(&config.logging)?;
|
||||||
run_mount(config)
|
run_mount(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user