diff --git a/src/main.rs b/src/main.rs index 0ae6f36..d92ace0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use std::{ io::prelude::*, boxed::Box, error::Error, + sync::Arc, }; use serde::Deserialize; use sqlx::{ @@ -14,6 +15,9 @@ use sqlx::{ SqliteConnectOptions, }, }; +use tokio::{ + sync::RwLock, +}; const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; @@ -55,7 +59,11 @@ async fn main() -> Result<(), Box> { println!("{:?}", options); #[cfg(feature = "sqlite")] - let sqlite_connection = connect_sqlite(&config.database_path).await?; + let sqlite_connection = Arc::new( + RwLock::new( + connect_sqlite(&config.database_path).await? + ) + ); Ok(()) }