blob: e29f6918760aa60ed3c14b2623f659c379c52721 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
mod config;
mod system;
mod listener;
use std::thread::{self, JoinHandle};
use tokio::runtime;
use system::System;
fn main() {
let config_str = include_str!("../config.toml");
let config = config::Config::load(config_str.to_string());
let handles : Vec<_> = config.systems.into_iter().map(|(system_name, system_config)| -> JoinHandle<()> {
thread::spawn(move || {
let runtime = runtime::Builder::new_current_thread().enable_all().build().expect("Could not construct Tokio runtime");
runtime.block_on(async {
let mut system = System::new(system_name, system_config);
system.start_clients().await;
})
})
}).collect();
for thread_handle in handles.into_iter() {
thread_handle.join().expect("Child thread has panicked");
}
}
|