Skip to content

Commit

Permalink
修复在docker中无法正常关闭的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Chikage0o0 committed Oct 16, 2023
1 parent b913130 commit 5c548da
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions matrix_bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async fn main() {
let _ = load_plugins(&matrix_client, args.data.join("plugins"), &args.plugins);

let ctrlc = tokio::signal::ctrl_c();
let mut term= tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).unwrap();

let client = matrix_client.clone();

Expand All @@ -70,6 +71,21 @@ async fn main() {
.await
});

#[cfg(unix)]
tokio::select! {
_=ctrlc => {
log::info!("Ctrl-c received, stopping");
}
_=handle => {
log::error!("Syncing stopped");
}

_=term.recv() => {
log::info!("SIGTERM received, stopping");
}
}

#[cfg(not(unix))]
tokio::select! {
_=ctrlc => {
log::info!("Ctrl-c received, stopping");
Expand Down

0 comments on commit 5c548da

Please sign in to comment.