use std::net::SocketAddr; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use what2watch::get_db_pool; fn main() { tracing_subscriber::registry() .with( tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| "what2watch=debug,axum::routing=debug".into()), ) .with(tracing_subscriber::fmt::layer()) .init(); //tracing_subscriber::fmt().with_target(false).pretty().init(); let pool = get_db_pool(); let rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap(); let app = rt.block_on(what2watch::app(pool.clone())); rt.block_on(async { let addr: SocketAddr = ([0, 0, 0, 0], 3000).into(); tracing::debug!("binding to {addr:?}"); let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); axum::serve(listener, app).await.unwrap(); }); rt.block_on(pool.close()); }