use clap::Parser; use log::info; use tokio::sync::mpsc; use actor_system::{spawn_sync_actor}; #[derive(Parser, Debug)] #[command(name = "sync_actor")] #[command(about = "Sync Actor - processes jobs sequentially with DSL modules")] struct Args { /// Actor ID for this instance #[arg(short, long)] actor_id: String, /// Database path #[arg(short, long, default_value = "/tmp/actor_db")] db_path: String, /// Redis URL #[arg(short, long, default_value = "redis://localhost:6379")] redis_url: String, /// Preserve completed tasks in Redis (don't delete them) #[arg(short, long, default_value = "false")] preserve_tasks: bool, } #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); let args = Args::parse(); info!("Starting Sync Actor with ID: {}", args.actor_id); info!("Database path: {}", args.db_path); info!("Redis URL: {}", args.redis_url); info!("Preserve tasks: {}", args.preserve_tasks); // Create shutdown channel let (_shutdown_tx, shutdown_rx) = mpsc::channel::<()>(1); // Spawn the sync actor let handle = spawn_sync_actor( args.actor_id, args.db_path, args.redis_url, shutdown_rx, args.preserve_tasks, ); // Wait for the actor to complete match handle.await { Ok(result) => { match result { Ok(()) => { info!("Sync Actor completed successfully"); Ok(()) } Err(e) => { eprintln!("Sync Actor error: {}", e); Err(e) } } } Err(e) => { eprintln!("Failed to join sync actor task: {}", e); Err(Box::new(e)) } } }