Implement basic runner structure
This commit is contained in:
parent
23ae5613c7
commit
bf08d00922
2 changed files with 97 additions and 2 deletions
|
|
@ -1,9 +1,15 @@
|
|||
mod coordinator;
|
||||
mod server;
|
||||
|
||||
use tracing::error;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use tokio::task::JoinSet;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
use self::{coordinator::Coordinator, server::Server};
|
||||
|
||||
pub struct Runner {
|
||||
config: &'static Config,
|
||||
}
|
||||
|
|
@ -14,6 +20,26 @@ impl Runner {
|
|||
}
|
||||
|
||||
pub async fn run(&self) {
|
||||
error!("Runner not yet implemented");
|
||||
if self.config.runner_servers.is_empty() {
|
||||
error!("No servers specified in config");
|
||||
return;
|
||||
}
|
||||
|
||||
let names = self.config.runner_servers.keys().cloned().collect();
|
||||
let coordinator = Arc::new(Mutex::new(Coordinator::new(names)));
|
||||
|
||||
let mut tasks = JoinSet::new();
|
||||
for (name, config) in self.config.runner_servers.iter() {
|
||||
debug!("Launching task for server {name}");
|
||||
let mut server = Server::new(
|
||||
name.clone(),
|
||||
config,
|
||||
self.config.runner_ping_delay,
|
||||
coordinator.clone(),
|
||||
);
|
||||
tasks.spawn(async move { server.run().await });
|
||||
}
|
||||
|
||||
while tasks.join_next().await.is_some() {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue