|
@@ -11,7 +11,7 @@ use serde_json::json;
|
|
|
use std::{collections::HashSet, convert::Infallible, net::SocketAddr, time::Duration};
|
|
use std::{collections::HashSet, convert::Infallible, net::SocketAddr, time::Duration};
|
|
|
use tokio::{
|
|
use tokio::{
|
|
|
spawn,
|
|
spawn,
|
|
|
- sync::{broadcast, mpsc, oneshot},
|
|
|
|
|
|
|
+ sync::{mpsc, oneshot},
|
|
|
time::sleep,
|
|
time::sleep,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -44,12 +44,8 @@ async fn serve_extra_infos(
|
|
|
pub async fn server() {
|
|
pub async fn server() {
|
|
|
let (context_tx, context_rx) = mpsc::channel(32);
|
|
let (context_tx, context_rx) = mpsc::channel(32);
|
|
|
let request_tx = context_tx.clone();
|
|
let request_tx = context_tx.clone();
|
|
|
- let shutdown_cmd_tx = context_tx.clone();
|
|
|
|
|
- let (shutdown_tx, mut shutdown_rx) = broadcast::channel(16);
|
|
|
|
|
- let kill_context = shutdown_tx.subscribe();
|
|
|
|
|
|
|
|
|
|
- let context_manager =
|
|
|
|
|
- spawn(async move { create_context_manager(context_rx, kill_context).await });
|
|
|
|
|
|
|
+ spawn(async move { create_context_manager(context_rx).await });
|
|
|
|
|
|
|
|
let addr = SocketAddr::from(([127, 0, 0, 1], 8004));
|
|
let addr = SocketAddr::from(([127, 0, 0, 1], 8004));
|
|
|
let make_svc = make_service_fn(move |_conn: &AddrStream| {
|
|
let make_svc = make_service_fn(move |_conn: &AddrStream| {
|
|
@@ -75,13 +71,9 @@ pub async fn server() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async fn create_context_manager(
|
|
|
|
|
- context_rx: mpsc::Receiver<Command>,
|
|
|
|
|
- mut kill: broadcast::Receiver<()>,
|
|
|
|
|
-) {
|
|
|
|
|
|
|
+async fn create_context_manager(context_rx: mpsc::Receiver<Command>) {
|
|
|
tokio::select! {
|
|
tokio::select! {
|
|
|
create_context = context_manager(context_rx) => create_context,
|
|
create_context = context_manager(context_rx) => create_context,
|
|
|
- _ = kill.recv() => {println!("Shut down context_manager");},
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -98,9 +90,6 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
|
|
}
|
|
}
|
|
|
sleep(Duration::from_millis(1)).await;
|
|
sleep(Duration::from_millis(1)).await;
|
|
|
}
|
|
}
|
|
|
- Shutdown { shutdown_sig } => {
|
|
|
|
|
- drop(shutdown_sig);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -111,9 +100,6 @@ enum Command {
|
|
|
req: Request<Body>,
|
|
req: Request<Body>,
|
|
|
sender: oneshot::Sender<Result<Response<Body>, Infallible>>,
|
|
sender: oneshot::Sender<Result<Response<Body>, Infallible>>,
|
|
|
},
|
|
},
|
|
|
- Shutdown {
|
|
|
|
|
- shutdown_sig: broadcast::Sender<()>,
|
|
|
|
|
- },
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn add_extra_infos(extra_infos_pages: &mut Vec<String>, request: Bytes) -> Response<Body> {
|
|
fn add_extra_infos(extra_infos_pages: &mut Vec<String>, request: Bytes) -> Response<Body> {
|