Skip to content

Commit

Permalink
Add some debugging messages to HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofl committed Feb 28, 2024
1 parent c1ef34f commit bca473a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/servers/http.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use log::debug;
use log::{debug, info};

use tower_http::services::ServeDir;
use std::net::{SocketAddr, IpAddr};
Expand Down Expand Up @@ -35,10 +35,12 @@ impl HTTPRunner for Server {
// Get notified about the server's spawned task
let mut receiver = self.sender.subscribe();
loop {
info!("Started runner. Waiting to start...");
let m = receiver.recv().await.unwrap();

if m.terminate { return };
if m.connect {
info!("Command received: connect...");
// Spin and await the actual server here
// Parse the IP address string into an IpAddr
let ip: IpAddr = self.bind_address.parse().expect("Invalid IP address");
Expand All @@ -51,12 +53,13 @@ impl HTTPRunner for Server {
.serve(tower::make::Shared::new(service))
.with_graceful_shutdown(async {
loop {
info!("Running and waiting for command to finish");
let m = receiver.recv().await.unwrap();
if m.terminate { return };
if m.connect { continue } // Not for me. Go wait another msg
else { break }
}
debug!("Gracefully terminating the HTTP server");
info!("Gracefully terminating the HTTP server");
});

server.await.expect("server error");
Expand Down

0 comments on commit bca473a

Please sign in to comment.