first commit
This commit is contained in:
commit
dd6a740645
37 files changed
+5424
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
use anyhow::Context;
|
||||
use tempus::{config::Config, db, routes};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "tempus=info,tower_http=info".into()),
|
||||
)
|
||||
.init();
|
||||
|
||||
let config = Config::from_env()?;
|
||||
let pool = db::connect(&config.database_url)
|
||||
.await
|
||||
.with_context(|| format!("cannot open {}", config.database_url))?;
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(config.addr)
|
||||
.await
|
||||
.with_context(|| format!("cannot listen on {}", config.addr))?;
|
||||
tracing::info!(db = %config.database_url, "Tempus disponible sur http://{}", config.addr);
|
||||
axum::serve(listener, routes::app(pool))
|
||||
.with_graceful_shutdown(async {
|
||||
let _ = tokio::signal::ctrl_c().await;
|
||||
})
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user