Instrument rpc::Server::start
and reduce cleanup timeout again
This commit is contained in:
parent
63e7b9189d
commit
674fddac87
1 changed files with 83 additions and 63 deletions
|
@ -58,7 +58,7 @@ use tower::ServiceBuilder;
|
||||||
use tracing::{info_span, instrument, Instrument};
|
use tracing::{info_span, instrument, Instrument};
|
||||||
|
|
||||||
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(5);
|
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
pub const CLEANUP_TIMEOUT: Duration = Duration::from_secs(20);
|
pub const CLEANUP_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref METRIC_CONNECTIONS: IntGauge =
|
static ref METRIC_CONNECTIONS: IntGauge =
|
||||||
|
@ -239,15 +239,27 @@ impl Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start(&self) -> Result<()> {
|
pub async fn start(&self) -> Result<()> {
|
||||||
self.app_state.db.delete_stale_projects().await?;
|
|
||||||
let db = self.app_state.db.clone();
|
let db = self.app_state.db.clone();
|
||||||
let peer = self.peer.clone();
|
let peer = self.peer.clone();
|
||||||
let timeout = self.executor.sleep(CLEANUP_TIMEOUT);
|
let timeout = self.executor.sleep(CLEANUP_TIMEOUT);
|
||||||
let pool = self.connection_pool.clone();
|
let pool = self.connection_pool.clone();
|
||||||
let live_kit_client = self.app_state.live_kit_client.clone();
|
let live_kit_client = self.app_state.live_kit_client.clone();
|
||||||
self.executor.spawn_detached(async move {
|
|
||||||
|
let span = info_span!("start server");
|
||||||
|
let span_enter = span.enter();
|
||||||
|
|
||||||
|
tracing::info!("begin deleting stale projects");
|
||||||
|
self.app_state.db.delete_stale_projects().await?;
|
||||||
|
tracing::info!("finish deleting stale projects");
|
||||||
|
|
||||||
|
drop(span_enter);
|
||||||
|
self.executor.spawn_detached(
|
||||||
|
async move {
|
||||||
|
tracing::info!("waiting for cleanup timeout");
|
||||||
timeout.await;
|
timeout.await;
|
||||||
|
tracing::info!("cleanup timeout expired, retrieving stale rooms");
|
||||||
if let Some(room_ids) = db.stale_room_ids().await.trace_err() {
|
if let Some(room_ids) = db.stale_room_ids().await.trace_err() {
|
||||||
|
tracing::info!(stale_room_count = room_ids.len(), "retrieved stale rooms");
|
||||||
for room_id in room_ids {
|
for room_id in room_ids {
|
||||||
let mut contacts_to_update = HashSet::default();
|
let mut contacts_to_update = HashSet::default();
|
||||||
let mut canceled_calls_to_user_ids = Vec::new();
|
let mut canceled_calls_to_user_ids = Vec::new();
|
||||||
|
@ -255,6 +267,11 @@ impl Server {
|
||||||
let mut delete_live_kit_room = false;
|
let mut delete_live_kit_room = false;
|
||||||
|
|
||||||
if let Ok(mut refreshed_room) = db.refresh_room(room_id).await {
|
if let Ok(mut refreshed_room) = db.refresh_room(room_id).await {
|
||||||
|
tracing::info!(
|
||||||
|
room_id = room_id.0,
|
||||||
|
new_participant_count = refreshed_room.room.participants.len(),
|
||||||
|
"refreshed room"
|
||||||
|
);
|
||||||
room_updated(&refreshed_room.room, &peer);
|
room_updated(&refreshed_room.room, &peer);
|
||||||
contacts_to_update
|
contacts_to_update
|
||||||
.extend(refreshed_room.stale_participant_user_ids.iter().copied());
|
.extend(refreshed_room.stale_participant_user_ids.iter().copied());
|
||||||
|
@ -293,7 +310,8 @@ impl Server {
|
||||||
..
|
..
|
||||||
} = contact
|
} = contact
|
||||||
{
|
{
|
||||||
for contact_conn_id in pool.user_connection_ids(contact_user_id)
|
for contact_conn_id in
|
||||||
|
pool.user_connection_ids(contact_user_id)
|
||||||
{
|
{
|
||||||
peer.send(
|
peer.send(
|
||||||
contact_conn_id,
|
contact_conn_id,
|
||||||
|
@ -320,7 +338,9 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
.instrument(span),
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue