Added the watch and scheduler systems
All checks were successful
CI / check (push) Successful in 1m10s
CI / docker (push) Successful in 2m40s

This commit is contained in:
Connor Johnstone
2026-03-20 16:28:15 -04:00
parent 4ec47252d9
commit 4008b4d838
8 changed files with 54 additions and 5 deletions

1
Cargo.lock generated
View File

@@ -3304,6 +3304,7 @@ dependencies = [
"sea-orm",
"serde",
"serde_json",
"shanty-data",
"shanty-db",
"shanty-tag",
"strsim",

View File

@@ -35,6 +35,9 @@ pub struct AppConfig {
#[serde(default)]
pub metadata: MetadataConfig,
#[serde(default)]
pub scheduling: SchedulingConfig,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -130,6 +133,36 @@ pub struct MetadataConfig {
pub fanart_api_key: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SchedulingConfig {
/// Enable automatic pipeline runs.
#[serde(default)]
pub pipeline_enabled: bool,
/// Hours between pipeline runs (after previous completion).
#[serde(default = "default_pipeline_interval_hours")]
pub pipeline_interval_hours: u32,
/// Enable automatic new release checking for monitored artists.
#[serde(default)]
pub monitor_enabled: bool,
/// Hours between monitor checks.
#[serde(default = "default_monitor_interval_hours")]
pub monitor_interval_hours: u32,
}
impl Default for SchedulingConfig {
fn default() -> Self {
Self {
pipeline_enabled: true,
pipeline_interval_hours: default_pipeline_interval_hours(),
monitor_enabled: true,
monitor_interval_hours: default_monitor_interval_hours(),
}
}
}
// --- Defaults ---
impl Default for AppConfig {
@@ -145,6 +178,7 @@ impl Default for AppConfig {
download: DownloadConfig::default(),
indexing: IndexingConfig::default(),
metadata: MetadataConfig::default(),
scheduling: SchedulingConfig::default(),
}
}
}
@@ -272,6 +306,12 @@ fn default_lyrics_source() -> String {
fn default_cover_art_source() -> String {
"coverartarchive".to_string()
}
fn default_pipeline_interval_hours() -> u32 {
3
}
fn default_monitor_interval_hours() -> u32 {
12
}
fn default_cookie_refresh_hours() -> u32 {
6
}

View File

@@ -10,7 +10,7 @@ fn test_default_config() {
assert!(!config.tagging.auto_tag);
assert_eq!(config.download.format, "opus");
assert_eq!(config.download.search_source, "ytmusic");
assert_eq!(config.download.rate_limit, 450);
assert_eq!(config.download.rate_limit, 250);
assert_eq!(config.download.rate_limit_auth, 1800);
assert_eq!(config.indexing.concurrency, 4);
assert!(config.allowed_secondary_types.is_empty());

View File

@@ -74,11 +74,19 @@ async fn main() -> anyhow::Result<()> {
config_path,
tasks: TaskManager::new(),
firefox_login: tokio::sync::Mutex::new(None),
scheduler: tokio::sync::Mutex::new(shanty_web::state::SchedulerInfo {
next_pipeline: None,
next_monitor: None,
}),
});
// Start background cookie refresh task
shanty_web::cookie_refresh::spawn(state.config.clone());
// Start pipeline and monitor schedulers
shanty_web::pipeline_scheduler::spawn(state.clone());
shanty_web::monitor::spawn(state.clone());
// Resolve static files directory
let static_dir = std::env::current_exe()
.ok()