//! Hero Supervisor Binary use hero_supervisor::{SupervisorApp, SupervisorBuilder}; use clap::Parser; use log::error; /// Hero Supervisor - manages actors and dispatches jobs #[derive(Parser, Debug)] #[command(name = "supervisor")] #[command(about = "Hero Supervisor - manages actors and dispatches jobs")] struct Args { /// Redis URL for job queue #[arg(long, default_value = "redis://127.0.0.1:6379")] redis_url: String, /// Namespace for Redis keys #[arg(long, default_value = "")] namespace: String, /// Admin secrets (required, can be specified multiple times) #[arg(long = "admin-secret", value_name = "SECRET", required = true)] admin_secrets: Vec, /// User secrets (can be specified multiple times) #[arg(long = "user-secret", value_name = "SECRET")] user_secrets: Vec, /// Register secrets (can be specified multiple times) #[arg(long = "register-secret", value_name = "SECRET")] register_secrets: Vec, /// Port for OpenRPC HTTP server #[arg(long, default_value = "3030")] port: u16, /// Bind address for OpenRPC HTTP server #[arg(long, default_value = "127.0.0.1")] bind_address: String, /// Mycelium daemon URL (optional) #[arg(long, default_value = "")] mycelium_url: String, /// Mycelium topic for supervisor RPC messages #[arg(long, default_value = "supervisor.rpc")] topic: String, } #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); let args = Args::parse(); // Build supervisor let mut builder = SupervisorBuilder::new() .redis_url(&args.redis_url) .namespace(&args.namespace) .admin_secrets(args.admin_secrets); if !args.user_secrets.is_empty() { builder = builder.user_secrets(args.user_secrets); } if !args.register_secrets.is_empty() { builder = builder.register_secrets(args.register_secrets); } let supervisor = builder.build().await?; // Start OpenRPC server use std::sync::Arc; use tokio::sync::Mutex; use hero_supervisor::openrpc::start_http_openrpc_server; let supervisor_arc = Arc::new(Mutex::new(supervisor.clone())); let bind_addr = args.bind_address.clone(); let port = args.port; tokio::spawn(async move { match start_http_openrpc_server(supervisor_arc, &bind_addr, port).await { Ok(handle) => { handle.stopped().await; error!("OpenRPC server stopped unexpectedly"); } Err(e) => { error!("OpenRPC server error: {}", e); } } }); tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; // Print minimal startup info println!("📡 http://{}:{}", args.bind_address, args.port); #[cfg(feature = "mycelium")] if !args.mycelium_url.is_empty() { println!("🌐 {}", args.mycelium_url); } let mut app = SupervisorApp::new(supervisor, args.mycelium_url, args.topic); app.start().await?; Ok(()) }