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:
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user