openserve 2.0.3

A modern, high-performance, AI-enhanced file server built in Rust
Documentation
//! OpenServe - AI-Enhanced File Server
//! 
//! A modern, production-ready file server with AI capabilities powered by OpenAI.
//! Features intelligent file search, content summarization, and smart organization.

use anyhow::Result;
use clap::Parser;
use openserve::{
    config::Config,
    server::Server,
    telemetry,
    Args,
};
use std::sync::Arc;
use tracing::{info, error};

/// The main entry point of the OpenServe application.
///
/// This function performs the following steps:
/// 1. Parses command-line arguments.
/// 2. Initializes the application configuration from a file or arguments.
/// 3. Sets up the telemetry system (logging, metrics, tracing).
/// 4. Creates and runs the web server.
/// 5. Logs the server's graceful shutdown or any errors encountered.
#[tokio::main]
async fn main() -> Result<()> {
    // Parse command line arguments
    let args = Args::parse();

    // Initialize configuration
    let config = if let Some(config_path) = args.config {
        Config::from_file(&config_path)?
    } else {
        Config::from_args(&args)?
    };

    // Initialize telemetry
    telemetry::init(&config.telemetry)?;

    info!(
        "Starting OpenServe v{} with AI features {}",
        env!("CARGO_PKG_VERSION"),
        if config.ai.enabled { "enabled" } else { "disabled" }
    );

    // Create and start server
    let server = Server::new(Arc::new(config)).await?;
    
    match server.run().await {
        Ok(_) => {
            info!("Server stopped gracefully");
            Ok(())
        }
        Err(e) => {
            error!("Server error: {}", e);
            Err(e)
        }
    }
}