forked from kemitix/git-next
parent
53f66d5ee5
commit
869935dfc2
2 changed files with 10 additions and 11 deletions
|
@ -21,7 +21,9 @@ enum Server {
|
||||||
Init,
|
Init,
|
||||||
Start,
|
Start,
|
||||||
}
|
}
|
||||||
fn main() {
|
|
||||||
|
#[actix_rt::main]
|
||||||
|
async fn main() {
|
||||||
let fs = filesystem::FileSystem::new_real(None);
|
let fs = filesystem::FileSystem::new_real(None);
|
||||||
let net = Network::new_real();
|
let net = Network::new_real();
|
||||||
let commands = Commands::parse();
|
let commands = Commands::parse();
|
||||||
|
@ -35,7 +37,7 @@ fn main() {
|
||||||
server::init(fs);
|
server::init(fs);
|
||||||
}
|
}
|
||||||
Server::Start => {
|
Server::Start => {
|
||||||
server::start(fs, net);
|
server::start(fs, net).await;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub fn init(fs: FileSystem) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(fs: FileSystem, net: Network) {
|
pub async fn start(fs: FileSystem, net: Network) {
|
||||||
let Ok(_) = init_logging() else {
|
let Ok(_) = init_logging() else {
|
||||||
eprintln!("Failed to initialize logging.");
|
eprintln!("Failed to initialize logging.");
|
||||||
return;
|
return;
|
||||||
|
@ -49,17 +49,14 @@ pub fn start(fs: FileSystem, net: Network) {
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Config loaded");
|
info!("Config loaded");
|
||||||
let actors = config
|
let addresses = config
|
||||||
.forges()
|
.forges()
|
||||||
.flat_map(|(forge_name, forge)| create_forge_repos(forge, forge_name, &net))
|
.flat_map(|(forge_name, forge)| create_forge_repos(forge, forge_name, &net))
|
||||||
|
.map(start_actor)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
let _ = actix_rt::signal::ctrl_c().await;
|
||||||
actix::System::new().block_on(async {
|
info!("Ctrl-C received, shutting down...");
|
||||||
let addresses = actors.into_iter().map(start_actor).collect::<Vec<_>>();
|
drop(addresses);
|
||||||
let _ = actix_rt::signal::ctrl_c().await;
|
|
||||||
info!("Ctrl-C received, shutting down...");
|
|
||||||
drop(addresses);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_forge_repos(
|
fn create_forge_repos(
|
||||||
|
|
Loading…
Reference in a new issue