mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 04:38:19 +00:00
cmd_default: Add notifier to detect when rustical has started
This commit is contained in:
10
src/lib.rs
10
src/lib.rs
@@ -17,6 +17,7 @@ use rustical_store_sqlite::principal_store::SqlitePrincipalStore;
|
||||
use rustical_store_sqlite::{SqliteStore, create_db_pool};
|
||||
use setup_tracing::setup_tracing;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Notify;
|
||||
use tokio::sync::mpsc::Receiver;
|
||||
use tower::Layer;
|
||||
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)]
|
||||
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);
|
||||
|
||||
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?;
|
||||
tasks.push(tokio::spawn(async move {
|
||||
info!("RustiCal serving on http://{address}");
|
||||
if let Some(start_notifier) = start_notifier {
|
||||
start_notifier.notify_waiters();
|
||||
}
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}));
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
None => {
|
||||
let config: Config = parse_config()?;
|
||||
cmd_default(args, config).await
|
||||
cmd_default(args, config, None).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user