Define readiness probe to know when the new server can accept traffic

This commit is contained in:
Antonio Scandurra 2022-12-14 08:54:46 +01:00
parent 59c9a57570
commit 897506c797
4 changed files with 14 additions and 8 deletions

View file

@ -238,14 +238,14 @@ impl Server {
Arc::new(server)
}
pub fn start(&self) {
pub async fn start(&self) -> Result<()> {
self.app_state.db.delete_stale_projects().await?;
let db = self.app_state.db.clone();
let peer = self.peer.clone();
let timeout = self.executor.sleep(CLEANUP_TIMEOUT);
let pool = self.connection_pool.clone();
let live_kit_client = self.app_state.live_kit_client.clone();
let timeout = self.executor.sleep(CLEANUP_TIMEOUT);
self.executor.spawn_detached(async move {
db.delete_stale_projects().await.trace_err();
timeout.await;
if let Some(room_ids) = db.stale_room_ids().await.trace_err() {
for room_id in room_ids {
@ -321,6 +321,7 @@ impl Server {
}
}
});
Ok(())
}
pub fn teardown(&self) {