Skip to content

Commit

Permalink
Fix handling termination; Finish all tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nieznanysprawiciel committed Apr 11, 2024
1 parent d568370 commit ccd87ae
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ async fn try_main() -> anyhow::Result<()> {

let (signal_sender, signal_receiver) = mpsc::channel::<Signal>(1);

select! {
res = handle_cli(cli, signal_receiver) => res,
res = handle_signals(signal_sender) => res,
}
tokio::task::spawn_local(async move {
handle_signals(signal_sender)
.await
.inspect_err(|e| log::error!("Error waiting for signal: {e}"))
.ok();
});

handle_cli(cli, signal_receiver).await
}

async fn handle_cli(cli: Cli, signal_receiver: Receiver<Signal>) -> anyhow::Result<()> {
Expand Down

0 comments on commit ccd87ae

Please sign in to comment.