salvo icon indicating copy to clipboard operation
salvo copied to clipboard

tls-rustls-reload example not reloading periodically

Open mixaal opened this issue 8 months ago • 1 comments

Describe the bug

the tls-rustls-reload loads the certificates just once at the startup, it never re-attempts to go thru the loop inside the async stream again.

To Reproduce

This little code change makes it more clear, set the reloading duration to 1sec and put some debug messages around. The messages are seen only once as the sleep await is never woke up.

diff --git a/examples/tls-rustls-reload/src/main.rs b/examples/tls-rustls-reload/src/main.rs
index e7fe77bc..deda2a30 100644
--- a/examples/tls-rustls-reload/src/main.rs
+++ b/examples/tls-rustls-reload/src/main.rs
@@ -15,8 +15,10 @@ async fn main() {
     let acceptor = TcpListener::new("0.0.0.0:5800")
         .rustls(async_stream::stream! {
             loop {
+                tracing::info!("loading config...");
                 yield load_config();
-                tokio::time::sleep(Duration::from_secs(60)).await;
+                tracing::info!("sleeping...");
+                tokio::time::sleep(Duration::from_secs(1)).await;
             }
         })
         .bind()

Expected behavior I assume we want to see messages to appear every 1s tick.

Screenshots

Desktop (please complete the following information):

OS: Ubuntu 23.10

uname -a
Linux smurf 6.5.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 26 11:23:57 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

rustc version:

rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

mixaal avatar Jun 11 '24 17:06 mixaal