diff --git a/cmd/supervisor.rs b/cmd/supervisor.rs index 327b943..7ad86ca 100644 --- a/cmd/supervisor.rs +++ b/cmd/supervisor.rs @@ -133,8 +133,16 @@ async fn main() -> Result<(), Box> { 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); + match start_http_openrpc_server(supervisor_arc, &bind_addr, port).await { + Ok(handle) => { + info!("OpenRPC server started successfully"); + // Keep the server running by holding the handle + handle.stopped().await; + error!("OpenRPC server stopped unexpectedly"); + } + Err(e) => { + error!("OpenRPC server error: {}", e); + } } }); diff --git a/examples/osiris_openrpc/README.md b/examples/osiris_openrpc/README.md index 9bad09f..258e503 100644 --- a/examples/osiris_openrpc/README.md +++ b/examples/osiris_openrpc/README.md @@ -18,6 +18,14 @@ This example demonstrates the complete workflow of using Hero Supervisor with OS ## Prerequisites +**IMPORTANT: Redis must be running before starting this example!** + +```bash +# Start Redis (if not already running) +redis-server +``` + +Other requirements: - Redis server running on `localhost:6379` - Rust toolchain installed - Both `supervisor` and `runner_rust` crates available diff --git a/examples/osiris_openrpc/main.rs b/examples/osiris_openrpc/main.rs index 46ba078..55877f7 100644 --- a/examples/osiris_openrpc/main.rs +++ b/examples/osiris_openrpc/main.rs @@ -41,15 +41,29 @@ async fn main() -> Result<(), Box> { let mut supervisor = supervisor_binary.command() .arg("--redis-url") .arg("redis://localhost:6379") - .arg("--openrpc") - .arg("--openrpc-port") + .arg("--port") .arg("3030") - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) + .arg("--admin-secret") + .arg("admin_secret") + .arg("--user-secret") + .arg("user_secret") + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) .spawn()?; println!("✅ Supervisor started on port 3030"); - sleep(Duration::from_secs(2)).await; + println!("⏳ Waiting for supervisor to initialize..."); + sleep(Duration::from_secs(5)).await; + + // Check if supervisor is still running + match supervisor.try_wait()? { + Some(status) => { + return Err(format!("Supervisor exited early with status: {}", status).into()); + } + None => { + println!("✅ Supervisor is running"); + } + } // ======================================================================== // STEP 2: Build OSIRIS runner