feat: simplify OpenRPC API and reorganize examples
- Simplified RunnerConfig to just name, command, and optional env - Removed RunnerType and ProcessManagerType enums - Removed db_path, redis_url, binary_path from config - Made runner name also serve as queue name (no separate queue param) - Added secret-based authentication to all runner management methods - Created comprehensive osiris_openrpc example - Archived old examples to _archive/ - Updated client API to match simplified supervisor interface
This commit is contained in:
@@ -50,6 +50,14 @@ struct Args {
|
||||
/// Mycelium topic for supervisor RPC messages
|
||||
#[arg(long, default_value = "supervisor.rpc")]
|
||||
topic: String,
|
||||
|
||||
/// 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,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -97,6 +105,42 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
};
|
||||
|
||||
// Print startup information
|
||||
let server_url = format!("http://{}:{}", args.bind_address, args.port);
|
||||
println!("\n╔════════════════════════════════════════════════════════════╗");
|
||||
println!("║ Hero Supervisor Started ║");
|
||||
println!("╚════════════════════════════════════════════════════════════╝");
|
||||
println!(" 📡 OpenRPC Server: {}", server_url);
|
||||
println!(" 🔗 Redis: {}", args.redis_url);
|
||||
#[cfg(feature = "mycelium")]
|
||||
if !args.mycelium_url.is_empty() {
|
||||
println!(" 🌐 Mycelium: {}", args.mycelium_url);
|
||||
} else {
|
||||
println!(" 🌐 Mycelium: Disabled");
|
||||
}
|
||||
#[cfg(not(feature = "mycelium"))]
|
||||
println!(" 🌐 Mycelium: Not compiled (use --features mycelium)");
|
||||
println!("╚════════════════════════════════════════════════════════════╝\n");
|
||||
|
||||
// Start OpenRPC server in background
|
||||
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 {
|
||||
info!("Starting OpenRPC server on {}:{}", bind_addr, port);
|
||||
if let Err(e) = start_http_openrpc_server(supervisor_arc, &bind_addr, port).await {
|
||||
error!("OpenRPC server error: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
// Give the server a moment to start
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
||||
|
||||
let mut app = SupervisorApp::new(supervisor, args.mycelium_url, args.topic);
|
||||
|
||||
// Start the complete supervisor application
|
||||
|
||||
Reference in New Issue
Block a user