From 5e2aee9248a00c8b213a8e07e4796d668bff519c Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 7 Feb 2025 09:17:26 +0100 Subject: Apply SQL migrations at startup --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b2af6de..0a7bd56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use std::env; use std::net::SocketAddr; +use anyhow::Result; use hyper::server::conn::http1; use hyper::service::service_fn; use hyper_util::rt::TokioIo; use tokio::net::TcpListener; -use tokio_rusqlite::Connection; mod db; mod jobs; @@ -15,7 +15,7 @@ mod templates; mod util; #[tokio::main] -async fn main() -> std::result::Result<(), Box> { +async fn main() -> Result<()> { env_logger::init(); let host = get_env("HOST"); @@ -24,9 +24,7 @@ async fn main() -> std::result::Result<(), Box> { let authorized_key = get_env("KEY"); let files_dir = get_env("FILES_DIR"); - let db_conn = Connection::open(db_path) - .await - .expect("Error while openning DB conection"); + let db_conn = db::init(&db_path).await?; tokio::spawn(jobs::start(db_conn.clone(), files_dir.clone())); -- cgit v1.2.3