Added the watch and scheduler systems
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3304,6 +3304,7 @@ dependencies = [
|
|||||||
"sea-orm",
|
"sea-orm",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"shanty-data",
|
||||||
"shanty-db",
|
"shanty-db",
|
||||||
"shanty-tag",
|
"shanty-tag",
|
||||||
"strsim",
|
"strsim",
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ pub struct AppConfig {
|
|||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub metadata: MetadataConfig,
|
pub metadata: MetadataConfig,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub scheduling: SchedulingConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -130,6 +133,36 @@ pub struct MetadataConfig {
|
|||||||
pub fanart_api_key: Option<String>,
|
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 ---
|
// --- Defaults ---
|
||||||
|
|
||||||
impl Default for AppConfig {
|
impl Default for AppConfig {
|
||||||
@@ -145,6 +178,7 @@ impl Default for AppConfig {
|
|||||||
download: DownloadConfig::default(),
|
download: DownloadConfig::default(),
|
||||||
indexing: IndexingConfig::default(),
|
indexing: IndexingConfig::default(),
|
||||||
metadata: MetadataConfig::default(),
|
metadata: MetadataConfig::default(),
|
||||||
|
scheduling: SchedulingConfig::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,6 +306,12 @@ fn default_lyrics_source() -> String {
|
|||||||
fn default_cover_art_source() -> String {
|
fn default_cover_art_source() -> String {
|
||||||
"coverartarchive".to_string()
|
"coverartarchive".to_string()
|
||||||
}
|
}
|
||||||
|
fn default_pipeline_interval_hours() -> u32 {
|
||||||
|
3
|
||||||
|
}
|
||||||
|
fn default_monitor_interval_hours() -> u32 {
|
||||||
|
12
|
||||||
|
}
|
||||||
fn default_cookie_refresh_hours() -> u32 {
|
fn default_cookie_refresh_hours() -> u32 {
|
||||||
6
|
6
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fn test_default_config() {
|
|||||||
assert!(!config.tagging.auto_tag);
|
assert!(!config.tagging.auto_tag);
|
||||||
assert_eq!(config.download.format, "opus");
|
assert_eq!(config.download.format, "opus");
|
||||||
assert_eq!(config.download.search_source, "ytmusic");
|
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.download.rate_limit_auth, 1800);
|
||||||
assert_eq!(config.indexing.concurrency, 4);
|
assert_eq!(config.indexing.concurrency, 4);
|
||||||
assert!(config.allowed_secondary_types.is_empty());
|
assert!(config.allowed_secondary_types.is_empty());
|
||||||
|
|||||||
Submodule shanty-db updated: 9917ee981d...8a1435d9e9
Submodule shanty-tag updated: 2280e9564d...e5b3fc3fe3
Submodule shanty-watch updated: 15a4efe1e9...85e24671a3
Submodule shanty-web updated: eaaff5f98f...9d6c0e31c1
@@ -74,11 +74,19 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
config_path,
|
config_path,
|
||||||
tasks: TaskManager::new(),
|
tasks: TaskManager::new(),
|
||||||
firefox_login: tokio::sync::Mutex::new(None),
|
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
|
// Start background cookie refresh task
|
||||||
shanty_web::cookie_refresh::spawn(state.config.clone());
|
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
|
// Resolve static files directory
|
||||||
let static_dir = std::env::current_exe()
|
let static_dir = std::env::current_exe()
|
||||||
.ok()
|
.ok()
|
||||||
|
|||||||
Reference in New Issue
Block a user