diff --git a/teos/src/api/http.rs b/teos/src/api/http.rs index 644de14..ef0afe1 100644 --- a/teos/src/api/http.rs +++ b/teos/src/api/http.rs @@ -4,7 +4,7 @@ use std::error::Error; use std::net::SocketAddr; use tokio::time::Duration; use tonic::transport::Channel; -use triggered::Listener; +use triggered::{Listener, Trigger}; use warp::{http::StatusCode, reject, reply, Filter, Rejection, Reply}; use teos_common::appointment::LOCATOR_LEN; @@ -288,7 +288,12 @@ async fn handle_rejection(err: Rejection) -> Result { } } -pub async fn serve(http_bind: SocketAddr, grpc_bind: String, shutdown_signal: Listener) { +pub async fn serve( + http_bind: SocketAddr, + grpc_bind: String, + service_ready: Trigger, + shutdown_signal: Listener, +) { let grpc_conn = loop { match PublicTowerServicesClient::connect(grpc_bind.clone()).await { Ok(conn) => break conn, @@ -300,6 +305,7 @@ pub async fn serve(http_bind: SocketAddr, grpc_bind: String, shutdown_signal: Li }; let (_, server) = warp::serve(router(grpc_conn)) .bind_with_graceful_shutdown(http_bind, async { shutdown_signal.await }); + service_ready.trigger(); server.await } diff --git a/teos/src/main.rs b/teos/src/main.rs index 789f197..1fbd843 100644 --- a/teos/src/main.rs +++ b/teos/src/main.rs @@ -283,11 +283,14 @@ async fn main() { .unwrap(); }); + let (http_service_ready, ready_signal_http) = triggered::trigger(); let http_api_task = task::spawn(http::serve( http_api_addr, internal_rpc_api_uri, + http_service_ready, shutdown_signal_http, )); + ready_signal_http.await; // Add Tor Onion Service for public API let mut tor_task = Option::None;