remove unused dep and move job out
This commit is contained in:
35
src/app.rs
35
src/app.rs
@@ -6,6 +6,7 @@
|
||||
|
||||
use crate::Supervisor;
|
||||
use crate::openrpc::start_openrpc_servers;
|
||||
use crate::mycelium::MyceliumServer;
|
||||
use log::{info, error, debug};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
@@ -42,6 +43,9 @@ impl SupervisorApp {
|
||||
// Start OpenRPC server
|
||||
self.start_openrpc_server().await?;
|
||||
|
||||
// Start Mycelium server
|
||||
self.start_mycelium_server().await?;
|
||||
|
||||
// Set up graceful shutdown
|
||||
self.setup_graceful_shutdown().await;
|
||||
|
||||
@@ -146,6 +150,37 @@ impl SupervisorApp {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Start the Mycelium server
|
||||
async fn start_mycelium_server(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
info!("Starting Mycelium server...");
|
||||
|
||||
let supervisor_for_mycelium = Arc::new(Mutex::new(self.supervisor.clone()));
|
||||
let mycelium_port = 8990; // Standard Mycelium port
|
||||
let bind_address = "127.0.0.1".to_string();
|
||||
|
||||
let mycelium_server = MyceliumServer::new(
|
||||
supervisor_for_mycelium,
|
||||
bind_address,
|
||||
mycelium_port,
|
||||
);
|
||||
|
||||
// Start the Mycelium server in a background task
|
||||
let server_handle = tokio::spawn(async move {
|
||||
if let Err(e) = mycelium_server.start().await {
|
||||
error!("Mycelium server error: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
// Give the server a moment to start
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
|
||||
info!("Mycelium server started successfully on port {}", mycelium_port);
|
||||
|
||||
// Store the handle for potential cleanup
|
||||
std::mem::forget(server_handle); // For now, let it run in background
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get status of all runners
|
||||
pub async fn get_status(&self) -> Result<Vec<(String, String)>, Box<dyn std::error::Error>> {
|
||||
debug!("Getting status of all runners");
|
||||
|
Reference in New Issue
Block a user