fix: keep OpenRPC ServerHandle alive to prevent server shutdown

The ServerHandle was being dropped immediately after spawning, causing the
OpenRPC server to shut down. Now we properly await handle.stopped() to keep
the server running.
This commit is contained in:
Timur Gordon
2025-10-27 14:34:22 +01:00
parent 98b2718d58
commit a47157aa71
3 changed files with 37 additions and 7 deletions

View File

@@ -133,8 +133,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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);
}
}
});