diff --git a/config/pscand.toml b/config/pscand.toml index 7c8baee..950d28f 100644 --- a/config/pscand.toml +++ b/config/pscand.toml @@ -42,12 +42,8 @@ interval_secs = 30 # Battery status changes slowly enabled = true interval_secs = 5 -# Example: Disable a scanner -[scanners.system] -enabled = false - # Example: Custom scanner with extra parameters -[scanners.custom] -enabled = true -interval_secs = 60 -extra = { custom_param = "value", threshold = 100 } +# [scanners.custom] +# enabled = true +# interval_secs = 60 +# extra = { custom_param = "value", threshold = 100 } diff --git a/crates/pscand-cli/src/main.rs b/crates/pscand-cli/src/main.rs index ec1c362..91e7c7d 100644 --- a/crates/pscand-cli/src/main.rs +++ b/crates/pscand-cli/src/main.rs @@ -27,7 +27,7 @@ enum Args { #[derive(Parser, Debug)] struct RunArgs { - #[arg(short, long, default_value = "/etc/pscand/pscand.toml")] + #[arg(short, long, default_value = "~/.config/pscand/pscand.toml")] config: PathBuf, #[arg(short, long)] @@ -179,7 +179,16 @@ async fn run_daemon(args: RunArgs) -> Result<(), Box> { let config = if args.config.exists() { CoreConfig::load(&args.config)? } else { - log::warn!("Config file not found, using defaults"); + log::warn!("Config file not found at {:?}", args.config); + log::info!("Creating default config. Run with --config to specify a different path."); + + // Create default config directory if it doesn't exist + if let Some(parent) = args.config.parent() { + if let Err(e) = std::fs::create_dir_all(parent) { + log::warn!("Failed to create config directory: {}", e); + } + } + CoreConfig::default() }; @@ -256,8 +265,18 @@ async fn run_daemon(args: RunArgs) -> Result<(), Box> { let scanners = load_scanners(&config, &logger).await?; if scanners.is_empty() { - log::warn!("No scanners loaded!"); - logger.log(LogLevel::Warn, "daemon", "no_scanners", "{}".to_string()); + log::error!("No scanners loaded!"); + log::error!("Please ensure:"); + log::error!(" 1. Scanner plugins are installed in one of the configured directories"); + log::error!(" 2. Scanner directories are correctly set in config file or PSCAND_SCANNER_DIRS env var"); + log::error!(" 3. Scanners are not disabled in the configuration"); + logger.log( + LogLevel::Error, + "daemon", + "no_scanners", + "No scanner plugins loaded".to_string(), + ); + return Err("No scanners loaded. See error messages above.".into()); } else { log::info!("Loaded {} scanners", scanners.len()); logger.log( @@ -423,8 +442,12 @@ async fn load_scanners( ) -> Result, Box> { let mut loaded = Vec::new(); + let mut missing_dirs = Vec::new(); + for dir in &config.scanner_dirs { if !dir.exists() { + missing_dirs.push(dir.clone()); + log::warn!("Scanner directory does not exist: {:?}", dir); continue; } @@ -521,6 +544,14 @@ async fn load_scanners( } } + if !missing_dirs.is_empty() { + log::warn!("The following scanner directories do not exist:"); + for dir in &missing_dirs { + log::warn!(" - {:?}", dir); + } + log::info!("Create these directories or update scanner_dirs in config"); + } + Ok(loaded) }