Skip to content

Commit

Permalink
Fix shutdown hook
Browse files Browse the repository at this point in the history
  • Loading branch information
NyCodeGHG authored Dec 1, 2022
1 parent f624fe4 commit fede789
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ lazy_static = "1.4"
cached = "0.40"

[target.'cfg(unix)'.dependencies]
signal-hook-tokio = "0.3"
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
signal-hook = "0.3"
futures = "0.3"

[profile.release]
lto = true
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
collections::hash_map::DefaultHasher,
future,
hash::{Hash, Hasher},
};

Expand All @@ -21,6 +20,10 @@ use opentelemetry_prometheus::{PrometheusExporter, TextEncoder};
use reqwest::StatusCode;
use traewelling_exporter::traewelling::client::TraewellingClient;

#[cfg(unix)]
use futures::stream::StreamExt;
#[cfg(unix)]
use signal_hook::consts::*;
#[cfg(unix)]
use signal_hook_tokio::Signals;

Expand Down Expand Up @@ -85,7 +88,7 @@ async fn shutdown_signal() {

#[cfg(unix)]
async fn shutdown_signal() {
let signals =
let mut signals =
Signals::new(&[SIGTERM, SIGINT, SIGQUIT]).expect("Failed to create signal handler");

signals.next().await;
Expand Down

0 comments on commit fede789

Please sign in to comment.