fix(server): Prevent losing a task waker
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful

Closes kemitix/git-next#26
This commit is contained in:
Paul Campbell 2024-04-12 12:58:07 +01:00
parent 53f66d5ee5
commit 869935dfc2
2 changed files with 10 additions and 11 deletions

View file

@ -21,7 +21,9 @@ enum Server {
Init,
Start,
}
fn main() {
#[actix_rt::main]
async fn main() {
let fs = filesystem::FileSystem::new_real(None);
let net = Network::new_real();
let commands = Commands::parse();
@ -35,7 +37,7 @@ fn main() {
server::init(fs);
}
Server::Start => {
server::start(fs, net);
server::start(fs, net).await;
}
},
}

View file

@ -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 {
eprintln!("Failed to initialize logging.");
return;
@ -49,17 +49,14 @@ pub fn start(fs: FileSystem, net: Network) {
};
info!("Config loaded");
let actors = config
let addresses = config
.forges()
.flat_map(|(forge_name, forge)| create_forge_repos(forge, forge_name, &net))
.map(start_actor)
.collect::<Vec<_>>();
actix::System::new().block_on(async {
let addresses = actors.into_iter().map(start_actor).collect::<Vec<_>>();
let _ = actix_rt::signal::ctrl_c().await;
info!("Ctrl-C received, shutting down...");
drop(addresses);
});
let _ = actix_rt::signal::ctrl_c().await;
info!("Ctrl-C received, shutting down...");
drop(addresses);
}
fn create_forge_repos(