fix(server): resolve compilation issues due to increased logging
This commit is contained in:
parent
bcd03bf0d4
commit
00d771c15f
|
|
@ -34,7 +34,7 @@ impl Config {
|
|||
|
||||
// Log all environment variable loading with detailed information
|
||||
println!("\n📋 CONFIGURATION LOADING:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
|
||||
// Database Configuration
|
||||
let database_url = match env::var("DATABASE_URL") {
|
||||
|
|
@ -338,7 +338,7 @@ impl Config {
|
|||
};
|
||||
|
||||
println!("\n🔍 CONFIGURATION VALIDATION:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
|
||||
// Validate server address format
|
||||
if !config.server_address.contains(':') {
|
||||
|
|
@ -362,7 +362,7 @@ impl Config {
|
|||
config.validate_paths()?;
|
||||
|
||||
println!("\n📊 CONFIGURATION SUMMARY:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
println!("🌐 Server will bind to: {}", config.server_address);
|
||||
println!("📁 Upload directory: {}", config.upload_path);
|
||||
println!("👁️ Watch directory: {}", config.watch_folder);
|
||||
|
|
@ -375,7 +375,7 @@ impl Config {
|
|||
|
||||
// Warning checks
|
||||
println!("\n⚠️ CONFIGURATION WARNINGS:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
if config.jwt_secret == "your-secret-key" {
|
||||
println!("🚨 SECURITY WARNING: Using default JWT secret! Set JWT_SECRET environment variable in production!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use anyhow::Result;
|
|||
use chrono::Utc;
|
||||
use sqlx::Row;
|
||||
use uuid::Uuid;
|
||||
use tracing::{info, warn, error};
|
||||
|
||||
use super::Database;
|
||||
|
||||
|
|
@ -312,13 +313,16 @@ impl Database {
|
|||
let source = crate::models::Source {
|
||||
id: source_id,
|
||||
user_id: row.get("user_id"),
|
||||
name: source_name,
|
||||
source_type: source_type_str.try_into()
|
||||
.map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, row.get::<String, _>("name"), e))?,
|
||||
name: source_name.clone(),
|
||||
source_type: source_type_str.clone().try_into()
|
||||
.map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, source_name, e))?,
|
||||
enabled: row.get("enabled"),
|
||||
config: config_json,
|
||||
status: row.get::<String, _>("status").try_into()
|
||||
.map_err(|e| anyhow::anyhow!("Invalid source status '{}' for source '{}': {}", row.get::<String, _>("status"), row.get::<String, _>("name"), e))?,
|
||||
status: {
|
||||
let status_str: String = row.get("status");
|
||||
status_str.clone().try_into()
|
||||
.map_err(|e| anyhow::anyhow!("Invalid source status '{}' for source '{}': {}", status_str, source_name, e))?
|
||||
},
|
||||
last_sync_at: row.get("last_sync_at"),
|
||||
last_error: row.get("last_error"),
|
||||
last_error_at: row.get("last_error_at"),
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -6,6 +6,7 @@ use sqlx::Row;
|
|||
use std::sync::Arc;
|
||||
use tower_http::{cors::CorsLayer, services::{ServeDir, ServeFile}};
|
||||
use tracing::{info, error, warn};
|
||||
use anyhow;
|
||||
|
||||
use readur::{config::Config, db::Database, AppState, *};
|
||||
|
||||
|
|
@ -50,11 +51,11 @@ fn determine_static_files_path() -> std::path::PathBuf {
|
|||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
println!("\n🚀 READUR APPLICATION STARTUP");
|
||||
println!("=".repeat(60));
|
||||
println!("{}", "=".repeat(60));
|
||||
|
||||
// Load and validate configuration with comprehensive logging
|
||||
let config = match Config::from_env() {
|
||||
|
|
@ -72,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
// Log critical configuration values that affect startup
|
||||
println!("\n🔗 STARTUP CONFIGURATION:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
println!("🌐 Server will start on: {}", config.server_address);
|
||||
// Parse database URL safely without exposing credentials
|
||||
let db_info = if let Some(at_pos) = config.database_url.find('@') {
|
||||
|
|
@ -119,7 +120,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
// Create separate database pools for different workloads
|
||||
println!("\n🗄️ DATABASE CONNECTION:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
|
||||
let web_db = match Database::new_with_pool_config(&config.database_url, 20, 2).await {
|
||||
Ok(db) => {
|
||||
|
|
@ -352,7 +353,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
// Create universal source scheduler with background state (handles WebDAV, Local, S3)
|
||||
println!("\n📅 SCHEDULER INITIALIZATION:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
|
||||
let source_scheduler = Arc::new(readur::source_scheduler::SourceScheduler::new(background_state.clone()));
|
||||
println!("✅ Universal source scheduler created (handles WebDAV, Local, S3)");
|
||||
|
|
@ -416,7 +417,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.with_state(web_state.clone());
|
||||
|
||||
println!("\n🌐 STARTING HTTP SERVER:");
|
||||
println!("=".repeat(50));
|
||||
println!("{}", "=".repeat(50));
|
||||
|
||||
let listener = match tokio::net::TcpListener::bind(&config.server_address).await {
|
||||
Ok(listener) => {
|
||||
|
|
@ -435,13 +436,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
};
|
||||
|
||||
println!("\n🎉 READUR APPLICATION READY!");
|
||||
println!("=".repeat(60));
|
||||
println!("{}", "=".repeat(60));
|
||||
println!("🌐 Server: http://{}", config.server_address);
|
||||
println!("📁 Upload Directory: {}", config.upload_path);
|
||||
println!("👁️ Watch Directory: {}", config.watch_folder);
|
||||
println!("🔄 Source Scheduler: Will start in 30 seconds");
|
||||
println!("📋 Check logs above for any configuration warnings");
|
||||
println!("=".repeat(60));
|
||||
println!("{}", "=".repeat(60));
|
||||
|
||||
info!("🚀 Readur server is now running and accepting connections");
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ impl WebDAVService {
|
|||
|
||||
info!("🔗 Constructed test URL: {}", test_url);
|
||||
|
||||
let response = self.client
|
||||
let resp = self.client
|
||||
.request(Method::from_bytes(b"PROPFIND").unwrap(), &test_url)
|
||||
.basic_auth(&test_config.username, Some(&test_config.password))
|
||||
.header("Depth", "0")
|
||||
|
|
|
|||
Loading…
Reference in New Issue