working split configuration
This commit is contained in:
@@ -26,3 +26,7 @@ tonic-build = "0.12.3"
|
|||||||
tonic-reflection = "0.12.3"
|
tonic-reflection = "0.12.3"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "server"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|||||||
@@ -5,3 +5,6 @@ pub mod adresar;
|
|||||||
pub mod uctovnictvo;
|
pub mod uctovnictvo;
|
||||||
pub mod shared;
|
pub mod shared;
|
||||||
pub mod table_structure;
|
pub mod table_structure;
|
||||||
|
|
||||||
|
// Re-export run_server from the inner server module:
|
||||||
|
pub use server::run_server;
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
// src/main.rs
|
// server/src/main.rs
|
||||||
use std::env;
|
use std::env;
|
||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
use crate::db;
|
|
||||||
|
// Import from the external library crate (named `server`)
|
||||||
|
use server::run_server;
|
||||||
|
use server::db;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
// Initialize database
|
// Initialize database using library module `db`
|
||||||
let db_config = db::DatabaseConfig::from_env();
|
let db_config = db::DatabaseConfig::from_env();
|
||||||
let db_pool = db::create_pool(&db_config).await?;
|
let db_pool = db::create_pool(&db_config).await?;
|
||||||
|
|
||||||
match env::args().nth(1).as_deref() {
|
match env::args().nth(1).as_deref() {
|
||||||
Some("server") => server::run_server(db_pool).await?,
|
Some("server") => run_server(db_pool).await?,
|
||||||
_ => println!("Usage: cargo run -- [server|client]"),
|
_ => println!("Usage: cargo run -- [server|client]"),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user