35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use oxspeak_server_lib::config::AppConfig;
|
|
use oxspeak_server_lib::core::App;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Enable tracing
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter(
|
|
std::env::var("RUST_LOG")
|
|
// .unwrap_or_else(|_| "info,sqlx=debug,sea_orm=debug,sea_orm_migration=info".into()),
|
|
.unwrap_or_else(|_| "info,sqlx=debug,sea_orm=debug,sea_orm_migration=debug".into()),
|
|
)
|
|
.with_target(true)
|
|
.with_level(true)
|
|
.with_thread_ids(false)
|
|
.with_thread_names(false)
|
|
.init();
|
|
|
|
// Load or generate config
|
|
if !AppConfig::file_exists() {
|
|
AppConfig::gen_config()?;
|
|
tracing::info!(config_path = "config.toml", "Generated");
|
|
tracing::info!("Config generated, please edit config.toml");
|
|
return Ok(());
|
|
}
|
|
let config = AppConfig::load()?;
|
|
tracing::info!(?config, "Loaded config");
|
|
|
|
// 3. Build & Run
|
|
let app = App::build(config).await?;
|
|
app.run().await?;
|
|
|
|
Ok(())
|
|
}
|