2026-04-16 22:01:51 +08:00
|
|
|
use mnote_web::{build_app, AppConfig, AppState};
|
|
|
|
|
use tokio::net::TcpListener;
|
|
|
|
|
use tracing::info;
|
|
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
init_tracing();
|
|
|
|
|
|
|
|
|
|
let config = AppConfig::from_env();
|
|
|
|
|
let bind_addr = config.bind_addr.clone();
|
2026-04-29 12:24:44 +08:00
|
|
|
let public_bind_addr = config.public_bind_addr.clone();
|
2026-04-16 22:01:51 +08:00
|
|
|
let app = build_app(AppState::new(config));
|
|
|
|
|
let listener = TcpListener::bind(&bind_addr).await?;
|
|
|
|
|
|
2026-04-29 12:24:44 +08:00
|
|
|
info!(bind_addr = %bind_addr, public_bind_addr = %public_bind_addr, "mnote-web gateway 已启动");
|
2026-04-16 22:01:51 +08:00
|
|
|
axum::serve(listener, app).await?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn init_tracing() {
|
|
|
|
|
tracing_subscriber::fmt()
|
|
|
|
|
.with_target(false)
|
|
|
|
|
.compact()
|
|
|
|
|
.try_init()
|
|
|
|
|
.ok();
|
|
|
|
|
}
|