Compare commits

..

No commits in common. "27f611990519f77c482f259483674614198dbdd6" and "7851d6bb1256639c869a7a00a83120d2f3f20f79" have entirely different histories.

2 changed files with 8 additions and 17 deletions

View File

@ -3,7 +3,7 @@ use russh::keys::PublicKey;
use tokio::select; use tokio::select;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
use tracing::{debug, error}; use tracing::{debug, warn};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Ldap { pub struct Ldap {
@ -51,10 +51,9 @@ impl Ldap {
select! { select! {
res = conn.drive() => { res = conn.drive() => {
if let Err(err) = res { if let Err(err) = res {
error!("LDAP connection error: {}", err); warn!("LDAP connection error: {}", err);
} else { } else {
error!("LDAP connection lost"); debug!("LDAP drive has stopped, this should not happen?");
token.cancel();
} }
} }
_ = token.cancelled() => { _ = token.cancelled() => {

View File

@ -15,26 +15,18 @@ use siranga::web::{ForwardAuth, Service};
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tokio::select; use tokio::select;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, warn}; use tracing::{error, info, warn};
use tracing_subscriber::EnvFilter; use tracing_subscriber::EnvFilter;
use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::util::SubscriberInitExt;
async fn shutdown_task(token: CancellationToken) { async fn shutdown_task(token: CancellationToken) {
select! { tokio::signal::ctrl_c()
_ = tokio::signal::ctrl_c() => { .await
debug!("Received SIGINT"); .expect("Failed to listen for ctrl-c event");
}
_ = token.cancelled() => {
debug!("Application called for graceful shutdown");
}
}
info!("Starting graceful shutdown"); info!("Starting graceful shutdown");
token.cancel(); token.cancel();
select! { tokio::time::sleep(Duration::from_secs(5)).await;
_ = tokio::time::sleep(Duration::from_secs(5)) => {}
_ = tokio::signal::ctrl_c() => {}
}
} }
#[tokio::main] #[tokio::main]