cmd_default: Add notifier to detect when rustical has started

This commit is contained in:
Lennart K
2026-01-28 20:16:41 +01:00
parent af60a446ad
commit c1758e2cba
2 changed files with 10 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ use rustical_store_sqlite::principal_store::SqlitePrincipalStore;
use rustical_store_sqlite::{SqliteStore, create_db_pool}; use rustical_store_sqlite::{SqliteStore, create_db_pool};
use setup_tracing::setup_tracing; use setup_tracing::setup_tracing;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::Notify;
use tokio::sync::mpsc::Receiver; use tokio::sync::mpsc::Receiver;
use tower::Layer; use tower::Layer;
use tower_http::normalize_path::NormalizePathLayer; use tower_http::normalize_path::NormalizePathLayer;
@@ -105,7 +106,11 @@ pub async fn get_data_stores(
} }
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)] #[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
pub async fn cmd_default(args: Args, config: Config) -> Result<()> { pub async fn cmd_default(
args: Args,
config: Config,
start_notifier: Option<Arc<Notify>>,
) -> Result<()> {
setup_tracing(&config.tracing); setup_tracing(&config.tracing);
let (addr_store, cal_store, subscription_store, principal_store, update_recv) = let (addr_store, cal_store, subscription_store, principal_store, update_recv) =
@@ -144,6 +149,9 @@ pub async fn cmd_default(args: Args, config: Config) -> Result<()> {
let listener = tokio::net::TcpListener::bind(&address).await?; let listener = tokio::net::TcpListener::bind(&address).await?;
tasks.push(tokio::spawn(async move { tasks.push(tokio::spawn(async move {
info!("RustiCal serving on http://{address}"); info!("RustiCal serving on http://{address}");
if let Some(start_notifier) = start_notifier {
start_notifier.notify_waiters();
}
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();
})); }));

View File

@@ -28,7 +28,7 @@ async fn main() -> Result<()> {
} }
None => { None => {
let config: Config = parse_config()?; let config: Config = parse_config()?;
cmd_default(args, config).await cmd_default(args, config, None).await
} }
} }
} }